Toolbar
Toolbar is a row of app controls that the keyboard reaches as one stop, moving between the controls with the arrow keys.
<Toolbar aria-label="Note tools"> <Flex align="center" gap="2"> <ToolbarButton iconOnly aria-label="Back">{back}</ToolbarButton> <ToolbarTitle>Nature Walks</ToolbarTitle> </Flex> <ToolbarGroup> <ToolbarButton>Share</ToolbarButton> <ToolbarSeparator /> <ToolbarButton>Export</ToolbarButton> </ToolbarGroup></Toolbar>A Toolbar is the row that holds an app's controls, such as the buttons at the top of an editor. The whole row is one tab stop, and the arrow keys move between the controls inside it, as toolbars do on every platform. That keyboard behaviour, which comes from Base UI's Toolbar, is the reason to use a Toolbar instead of a Flex.
Put ToolbarButton in the row, not Button. A plain Button can't join the row's keyboard group, so it adds its own tab stop and the arrow keys skip it. ToolbarButton accepts every Button prop, and with render it can become a link or a menu trigger.
The row is one control tall at its size. With no size, a Toolbar is one step above the app's size, which is size 3 in a default app, and every control in the row uses that size unless it sets its own. The row spaces its clusters for you: group controls with a Flex, and one cluster sits at the start, two go to the ends, and three sit at the start, the centre and the end.
ToolbarGroup draws a capsule around controls that belong together, such as bold, italic and underline, and the buttons inside it are quiet by default. A ToolbarSeparator divides loose controls. ToolbarTitle names the row, and ToolbarOverflow moves the controls that don't fit into a menu.
The row itself is transparent, so it has no tone, emphasis or material. Set backdrop on the row when content passes behind it, and every control in the row uses the theme's material. A ToolbarGroup also accepts backdrop for itself.
Screen readers announce the row as a toolbar. Give it an aria-label that says what the tools are for, and give every icon-only ToolbarButton its own aria-label.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
The row
Toolbar
Toolbar is a row of app controls that the keyboard reaches as one stop, moving between the controls with the arrow keys.
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when content passes behind the row, such as in a floating header. |
orientation? | "horizontal" | "vertical" | Sets the direction of the row and of the arrow keys. |
size? | "1" | "2" | "3" | "4" | Sets the size step of every control in the row that doesn't set its own size. |
It also takes every prop of a <div>.
What goes in it
ToolbarButton
A Button that joins the toolbar's keyboard group, so the arrow keys reach it. It accepts every Button prop, including render for a link or a menu trigger. It is medium by default, and quiet inside a ToolbarGroup
| Prop | Type | What it does |
|---|---|---|
aria-label? | string | The name of the button for screen readers. |
aria-labelledby? | string | The id of an element on the page that names this button. |
backdrop? | boolean | Set backdrop when the button sits over other content, such as an image. |
bordered? | boolean | Adds a thin border. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
done? | boolean | Shows a tick in place of the icon to say that the action finished. |
emphasis? | "loud" | "medium" | "quiet" | Sets how prominent the button is next to the buttons beside it. |
focusableWhenDisabled? | boolean | Keep focus on the button when it becomes disabled part-way through an interaction. |
iconOnly | true | Makes the button square and shows only the icon in children. |
leading? | React.ReactNode | Content before the label, usually an icon. |
loading? | boolean | Shows a spinner and blocks the press while an action runs. |
nativeButton? | boolean | Says whether the rendered element is a real <button>. |
render? | RenderElement | Renders the button as a different element, such as a link. |
size? | "1" | "2" | "3" | "4" | Sets the size step of the button, from 1 to 4. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
tone? | "neutral" | "accent" | "destructive" | "blue" | "green" | "orange" | "amber" | "pink" | "purple" | "success" | "warning" | "info" | Sets what the action means, and the theme picks the colour. |
trailing? | React.ReactNode | Content after the label, such as a chevron, a count or a control. |
It also takes every prop of a <button>.
ToolbarGroup
A capsule around controls that belong together, such as bold, italic and underline. It is as tall as a button beside it, and it uses the row's size, so the group and its buttons line up with the rest of the row
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when content passes behind the group. |
disabled? | boolean | Turns every control in the group off at once. |
It also takes every prop of a <div>.
Naming it
ToolbarTitle
The title at the start of the row. Give it words to show a fixed title. With no words, it shows the title of the Page in the same pane once that page's large title scrolls out of view, and it renders nothing when there is no title to show
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The title text. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
id? | string | The id of the title, so that you can point aria-labelledby at it. |
render? | React.ReactElement<{ className?: string; id?: string; style?: React.CSSProperties; children?: React.ReactNode }> | The element the title IS, when it must be more than words: a panel's own title part, so one heading both names the panel and sits in the row. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
When the row runs out of room
ToolbarOverflow
A group of controls that collapses into a ⋯ menu when the row runs out of room. It measures the space left in the row instead of using a breakpoint, because each toolbar holds different controls. A ToolbarButton that moves into the menu shows as a menu row, and your own components can call useToolbarOverflow() to render a different form there
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The controls in the cluster, in order. |
label? | string | The accessible name of the ⋯ button. |
It also takes every prop of a <div>.
tone,emphasisandmaterialon the row — The row itself is transparent, so there is nothing to colour or turn to glass. To make its controls use the theme's material, setbackdropon the row or on aToolbarGroup.- Leading, centre and trailing parts — Which controls sit at each end depends on what they mean in your app. Group them with a
Flex, and the row spaces the groups. sizeon a group — A group and its buttons always use the row's size, so they stay the same height as the controls beside them. Setsizeon theToolbarinstead.- A
gapprop — The row sets the space between clusters for you. Inside one cluster, setgapon theFlexthat groups the controls.