Toolbar
Holds a row of actions on one thing.
Sizes
defaultdefault
sm
Item
text
icon
toggle
with primary
States
rest
hover
held
focus-visible
pressed
disabled
Usage
When to use it
- Use
- Three or more actions on one thing: copy, retry and edit under an answer; run, export and wrap over an output.
- Use
- On or off settings for a view beside its actions (ToolbarToggle).
- Use
- A row that should be one tab stop, with the arrow keys inside it.
- Not for
- One or two actions; put Buttons side by side. Use Button.
- Not for
- Previous and next, or actions joined into one pill. Use Button group.
- Not for
- One view of several. Use Segmented control.
- Not for
- Actions on selected rows. Use Bulk action bar.
- Not for
- Site navigation: use links in a nav.
Rules
8 rules
- Must
- Name the Toolbar with aria-label for the thing its items act on. Because a screen reader announces "toolbar" alone, and two on one screen cannot be told apart.
- Must
- Give an iconOnly item an aria-label that says the action. Because an icon item has no text, so it is announced as "button" with no name.
- Must
- Give a toolbar at most one variant="primary", "confirm" or "destructive" item, at the end; leave the rest ghost. Because the toolbar is one group of actions, and two glass pills in it split the eye.
- Must
- Use ToolbarToggle for an on or off setting; never a ToolbarButton that changes its own look. Because the toggle sets aria-pressed and the pressed wash, and a button restyled by hand is announced as a plain button.
- Never
- Put glass on a pressed ToolbarToggle. Because a pressed toggle is a thing you have your hand on, which takes the pressed wash; glass marks a value chosen inside a control or the one lead.
- Never
- Draw a track, a border or a fill around the toolbar. Because Glaze toolbars are flat, and a grey track reads as a segmented control.
- Should
- Split items into ToolbarGroups with a ToolbarSeparator between kinds: actions, then settings.
- Should
- Keep it to about eight items; move the rest into a Dropdown menu behind a More item. Because the row never wraps, so items past the edge scroll out of sight.
State order
6 states, highest first
- 1
- disabled
- 2
- held
- 3
- focus-visible
- 4
- pressed
- 5
- hover
- 6
- rest
Accessibility
4 checks
- role="toolbar" named by aria-label; one Tab stop, arrow keys move between items, Home and End go to the ends.
- A toggle reports aria-pressed; the wash is not the only sign.
- Focus is the 2px ink ring on the item; the toolbar keeps 4px of room so a scrolling row never clips it.
- Arrow keys follow the reading direction in right to left.
Keyboard
4 keys
- Tab
- Enters and leaves the toolbar.
- Arrow left, Arrow right
- Moves between items, wrapping at the ends.
- Home, End
- Goes to the first or last item.
- Enter, Space
- Presses the item, or flips a toggle.
Edge cases
5 edge cases
- Wider than its container
- Scrolls sideways with no bar; items never wrap.
- Disabled item
- Turns grey and stays focusable, so arrow keys keep their place.
- Pending item
- Shows the arc at its size and refuses presses; the other items stay live.
- Toolbar on the shell footer
- Ghost items wash on the grey; pass size="sm" to match the footer's 26px actions.
- Dark theme
- The wash turns light; a primary turns to light glass with an ink label.
API
7 props
Toolbar size'default' | 'sm'default'default'Toolbar orientation, loopFocus, aria-labelBase UI Toolbar.Rootdefault'horizontal', trueToolbarButton variant'ghost' | 'secondary' | 'primary' | 'confirm' | 'destructive'default'ghost'ToolbarButton iconOnly, pendingbooleandefaultfalseToolbarToggle pressed, defaultPressed, onPressedChangeBase UI ToggleToolbarGroup disabledbooleandefaultfalseToolbarSeparatorBase UI Toolbar.Separator
Tokens
11 tokens
--hover- rgb(5 5 5 / 0.06)
--pressed- rgb(5 5 5 / 0.10)
--line- rgb(5 5 5 / 0.10)
--text-1- rgb(5 5 5 / 0.80)
--text-2- rgb(5 5 5 / 0.60)
--text-disabled- rgb(5 5 5 / 0.32)
--control- 32px
--control-sm- 26px
--radius-pill- 999px
--type-label- 500 13px/1.35 var(--font-sans)
--type-label-sm- 500 12px/1.35 var(--font-sans)