Toolbar
Accessible toolbar with toggle groups and roving tabindex keyboard navigation
Source
Package
Usage
Toolbar is a group of toggle buttons with role="toolbar" and arrow keys navigation.
Toolbar.Toggle is stateless: pass active and update it in onClick, or use Toolbar.ToggleGroup
to manage a set of toggles. For a toggle that manages its own state, use Toggle:
Toggle groups
Use Toolbar.ToggleGroup with Toolbar.ToggleItem to create groups of toggle buttons.
Set type="single" to allow one active item at a time or type="multiple" to allow several.
With type="single", clicking the active item deselects it and the value becomes null:
Size, orientation, variant and color
size prop sets the size of all toggles, padding and gap. Set orientation="vertical"
to render a vertical toolbar. variant and color props change the appearance of active toggles:
Auto width
By default, toggles are square buttons. Set autoWidth prop on Toolbar.Toggle or Toolbar.ToggleItem
to fit the width to the content, for example, a text label:
Disabled state
Set disabled prop on individual Toolbar.ToggleItem components, or on
Toolbar.ToggleGroup to disable all items in the group.
When Toolbar.Toggle is rendered as a non-button element, for example, component="a", the disabled prop
sets aria-disabled, removes the element from the tab order and prevents clicks:
Accessibility
Name the toolbar and give each icon-only toggle a label:
Keyboard interactions
Toggles share a single tab stop, arrow keys move focus between them.
Other interactive children, for example, ActionIcon or Button, remain separate tab stops.