Skip to content

Toolbar

A container for groups of tool controls: role="toolbar" + aria-label, Tab enters and arrow keys move between controls (roving tabindex — only the current item is focused). Ships with three companion widgets — toggle group, separator, input — plus vertical layout, loop toggle, whole-bar disabled, size steps, overflow collapse and attached look.

Basic usage (native buttons)

Basic usage (native buttons)

Toggle group (editor scenario)

oas-toolbar-toggle is the toolbar's toggle-group widget: single-select (default, radio semantics — mutually exclusive, clicking the selected item does nothing) and multiple-select (multiple, each item toggles independently). value is controlled (string for single / JSON array string for multiple); clicks emit oas-change. Use a multiple group for bold/italic/underline and a single group for alignment — the core editor toolbar shape.

Toggle group (bold/italic + alignment)

Style: bold, underline | Align: left

Separator widget

oas-toolbar-separator replaces the old oas-divider + data-toolbar-ignore combo: it sets role="separator" automatically, is excluded from roving navigation, and its line direction follows the toolbar orientation (vertical line inside a horizontal toolbar, horizontal line inside a vertical one).

oas-button + separator

CutCopyPasteUndoRedo

Vertical toolbar

orientation="vertical": aria-orientation="vertical" + vertical layout, / navigate along the axis (/ still work); the separator becomes a horizontal line.

Vertical toolbar

Loop navigation toggle

loop is on by default (arrow keys wrap around the ends); with loop="false" navigation stops at the ends.

loop=false no wrap

Size steps

size: small / medium (default) / large. Affects toolbar spacing, native buttons and the built-in widgets (toggle group / input follow automatically).

size steps

Whole-bar disabled

disabled disables the whole toolbar (aria-disabled + inert, items skip roving); adding focusable-when-disabled keeps items focusable (aria-disabled, clicks are blocked — handy for tooltips explaining why).

Whole-bar disabled

Disabled items

Buttons with disabled / aria-disabled are skipped by arrow-key navigation (roving skips them).

Disabled items

a[href] items join roving automatically and get part="link" (unified link styling and focus ring).

Link item

Help center

Far-aligned group

Add data-toolbar-far to an item: everything from that item onward is pushed to the far end (right-aligned in a horizontal toolbar, bottom-aligned in a vertical one) — handy for "primary actions left, settings/help right".

Far-aligned group

Toolbar input widget

oas-toolbar-input: joins roving as a single tab stop (composite special case — while focus is inside the input, arrow keys are consumed by text editing; Tab leaves and toolbar navigation continues). oas-input fires while typing, oas-change on Enter/blur commit.

Toolbar input

input: -

Overflow collapse (narrow container)

When the container is too narrow, overflowing items are folded into a "···" popup (ResizeObserver watches the width; click "···" to open mirrored items, clicking a mirror dispatches to the original control; the "···" highlights when a selected value is folded inside). Try shrinking the container below.

Overflow collapse

Attached look (is-attached)

is-attached: containerized toolbar appearance (border + background + padding), nice when mounted next to another toolbar/panel.

is-attached

API

oas-toolbar

AttributeDescriptionTypeDefault
disabledDisable the whole toolbar (aria-disabled + inert; items skip roving)boolean
focusable-when-disabledKeep items focusable while disabled (aria-disabled + clicks blocked; handy for tooltips explaining why)boolean
loopWrap-around arrow navigation: on by default; false stops at the endsstring
orientationLayout direction: horizontal (default) / vertical (arrow navigation follows the axis; separator becomes a horizontal line)stringhorizontal
sizeSize step: small / medium (default) / largestring
NameDescription
defaultToolbar controls: buttons / oas-button / toggle group / input / links / separators, etc.

oas-toolbar-toggle

AttributeDescriptionTypeDefault
disabledDisable the whole groupboolean
itemsOptions JSON (property assignment reflects one-way to the attribute)ToolbarToggleItem[] | string[]
multipleMultiple-select mode (each item toggles independently)boolean
sizeSize step (small/medium/large); defaults to the nearest oas-toolbar's sizestring
valueCurrent value: string for single-select; JSON array string for multiple-selectstring
EventDescription
oas-changeToggle, detail: { value: string | string[] }

oas-toolbar-input

AttributeDescriptionTypeDefault
disabledDisabledboolean
placeholderPlaceholder textstring
sizeSize step (small/medium/large); defaults to the nearest oas-toolbar's sizestring
valuePreset value (controlled entry; events do not write back, listen to update)string
EventDescription
oas-changeCommitted on Enter or blur, detail: { value }
oas-inputWhile typing, detail: { value }
  • The host has role="toolbar" + aria-orientation; aria-label comes from the locale key (toolbar.label)
  • Children that join roving: native controls (button/input/select/textarea/a[href]), interactive roles, custom elements (tag contains -); oas-toolbar-separator, data-toolbar-ignore and aria-hidden are excluded, disabled/aria-disabled are skipped automatically (aria-disabled items stay focusable in focusable-when-disabled mode)
  • Keyboard: Tab enters (only the current item is tab-reachable), / (or /) moves between controls, Home/End jumps to the first/last; while focus is inside the toggle group/input the arrow keys belong to the widget (Tab leaves and toolbar navigation continues)
  • Overflow collapse: ResizeObserver watches the width, overflowing items fold into a "···" popup (horizontal only)

Released under the MIT OR Apache-2.0 License.