Toolbar
A container for grouping a set of buttons and controls.
Usage guidelines
To ensure that toolbars are accessible and helpful, follow these guidelines:
- Use inputs sparingly: Left and right arrow keys are used to both move the text insertion cursor in an input, and to navigate among controls in horizontal toolbars. When using an input in a horizontal toolbar, use only one and place it as the last element of the toolbar.
Anatomy
Import the component and assemble its parts:
Examples
Using with other components
Use the render prop to combine a toolbar part with a part from another component into a single element.
The element joins the toolbar’s keyboard navigation and keeps the behavior of the other part.
- Popups with a trigger, such as Alert Dialog, Dialog, Drawer, Menu, Popover, and Select: pass the trigger to the
renderprop of<Toolbar.Button>, as shown above. Setdisabledon<Toolbar.Button>rather than on the trigger, so the button stays in the toolbar’s keyboard navigation. - Tooltip: pass
<Toolbar.Button>to therenderprop of<Tooltip.Trigger>instead. - Number Field: pass
<NumberField.Input>to therenderprop of<Toolbar.Input>, and keep it inside<NumberField.Root>and<NumberField.Group>with the increment and decrement buttons.
See how props are merged for how the two parts combine.
API reference
Root
A container for grouping a set of controls, such as buttons, toggle groups, or menus.
Renders a <div> element.
loopFocusbooleantrue
- Name
- Description
If
true, using keyboard navigation will wrap focus to the other end of the toolbar once the end is reached.- Type
- Default
true
disabledboolean—
- Name
- Type
orientationToolbar.Root.Orientation'horizontal'
- Name
- Description
The orientation of the toolbar.
- Type
- Default
'horizontal'
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the toolbar.
data-disabled
Present when the toolbar is disabled.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the toolbar. | |
data-disabled | Present when the toolbar is disabled. | |
Toolbar.Root.StateHide
Toolbar.Root.OrientationHide
Toolbar.Root.ItemMetadataHide
Button
A button that can be used as-is or as a trigger for other components.
Renders a <button> element.
focusableWhenDisabledbooleantrue
- Description
When
truethe item remains focusable when disabled.- Type
- Default
true
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
- Default
true
disabledbooleanfalse
- Name
- Description
When
truethe item is disabled.- Type
- Default
false
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the toolbar.
data-disabled
Present when the button is disabled.
data-focusable
Present when the button remains focusable when disabled.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the toolbar. | |
data-disabled | Present when the button is disabled. | |
data-focusable | Present when the button remains focusable when disabled. | |
Link
A link component.
Renders an <a> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the toolbar.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the toolbar. | |
Toolbar.Link.StateHide
Input
A native input element that integrates with Toolbar keyboard navigation.
Renders an <input> element.
defaultValueUnion—
- Name
- Type
focusableWhenDisabledbooleantrue
- Description
When
truethe item remains focusable when disabled.- Type
- Default
true
disabledbooleanfalse
- Name
- Description
When
truethe item is disabled.- Type
- Default
false
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the toolbar.
data-disabled
Present when the input is disabled.
data-focusable
Present when the input remains focusable when disabled.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the toolbar. | |
data-disabled | Present when the input is disabled. | |
data-focusable | Present when the input remains focusable when disabled. | |
Toolbar.Input.StateHide
Group
Groups several toolbar items or toggles.
Renders a <div> element.
disabledbooleanfalse
- Name
- Description
When
trueall toolbar items in the group are disabled.- Type
- Default
false
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the toolbar.
data-disabled
Present when the group is disabled.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the toolbar. | |
data-disabled | Present when the group is disabled. | |
Toolbar.Group.StateHide
Separator
A separator element accessible to screen readers.
Renders a <div> element.
orientationOrientation—
- Name
- Description
The orientation of the separator. Defaults to the opposite of the toolbar’s orientation, so a horizontal toolbar renders vertical separators.
- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the separator, which is perpendicular to the toolbar.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the separator, which is perpendicular to the toolbar. | |