Toolbar
A toolbar groups the actions that apply to what is on screen. Docked, it is a full-width bar at the bottom of a surface; floating, it is a pill raised above content, optionally paired with a FAB. It has no shadcn equivalent, so there is nothing to swap in. It is one tab stop, and the arrow keys move between its buttons.
Install
npx shadcn@latest add @nelumbo/toolbarDocked
Full width, 64px tall, a tonal surface with the items spread evenly. Pressed toggles fill their glyph and morph from a pill into a rounded square. This one uses overflow: shrink the window and the buttons that no longer fit move into a More menu.
Studio notes
Spring palette review
We tested the warm and cool neutrals against the new brand accent and kept the ones that hold their contrast in both themes.
Selected text takes the formatting from the toolbar below.
Floating with a FAB
A pill with an e3 shadow and its items packed. ToolbarFab lives in the same JSX but renders beside the bar, outside role=toolbar. The tool picker is a connected toggle group: the selected tool swells and its neighbours give way.
Vertical
orientation="vertical" turns the pill into a column for the edge of a screen. Arrow keys switch to Up and Down, and tooltips open inward (set edge="end" on the trailing edge). The right one is vibrant.
Colors
Standard sits on the surface ladder and pressed items turn inverse. Vibrant is inverse itself, with the pressed item flipping to the light fill. Brand uses the accent container. Each has a toggle group.
Collapse on scroll
Give a floating toolbar a collapsed state, usually from useToolbarCollapse. Shrink folds every item that is not marked keep into a small pill on a spring; hide slides the bar away and makes it inert. Docked toolbars always hide.
Scroll the article: it collapses while you scroll down and returns on the way up.
Designing with springs
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Motion that follows a damped spring feels physical because it starts fast and settles without passing its target. Tune stiffness for how quickly a control reacts and damping for how gently it lands, then reuse the same few curves everywhere.
Overflow
Set overflow and the toolbar measures its room. Items that do not fit move, in order, into a More menu; toggles show as checked items. Resize the demo to watch it.
// Manual pattern: your own menu in the last slot<Toolbar aria-label="Actions"> <ToolbarButton icon="edit" label="Edit" /> <DropdownMenu> <DropdownMenuTrigger asChild> <ToolbarButton icon="more_horiz" label="More" /> </DropdownMenuTrigger> <DropdownMenuContent>{/* ... */}</DropdownMenuContent> </DropdownMenu></Toolbar>Keyboard
- Tab
- Moves focus into the toolbar, onto the last button you used, and out again on the next Tab. A toolbar is one tab stop.
- Left / Right
- Horizontal toolbars: previous and next item. Focus wraps at the ends.
- Up / Down
- Vertical toolbars: previous and next item.
- Home / End
- First and last item.
- Space / Enter
- Presses a button or flips a toggle. Toggles expose aria-pressed.
- Escape
- Closes the overflow menu and returns focus to its button.
Usage
<Toolbar aria-label="Text formatting" variant="floating"> <ToolbarButton toggle icon="format_bold" label="Bold" shortcut="⌘B" pressed={bold} onPressedChange={setBold} /> <ToolbarSeparator /> <ToolbarToggleGroup type="single" defaultValue="left" aria-label="Alignment"> <ToolbarToggleItem value="left" aria-label="Align left"><Icon name="format_align_left" /></ToolbarToggleItem> <ToolbarToggleItem value="center" aria-label="Align center"><Icon name="format_align_center" /></ToolbarToggleItem> </ToolbarToggleGroup> <ToolbarFab icon="edit" label="Compose" /></Toolbar>Props
Toolbar
| Prop | Type | Default | Notes |
|---|---|---|---|
| aria-label | string | required | Names the toolbar for screen readers |
| variant | "docked" | "floating" | "floating" | Docked: full width, 64px, tonal. Floating: raised pill |
| orientation | "horizontal" | "vertical" | "horizontal" | Sets aria-orientation and the arrow keys |
| color | "standard" | "vibrant" | "brand" | "standard" | Surface, inverse, or accent container |
| edge | "start" | "end" | "start" | Vertical: which edge it sits on (tooltips, hide direction) |
| collapsed | boolean | false | Collapse state, e.g. from useToolbarCollapse |
| collapse | "shrink" | "hide" | "shrink" | Docked toolbars always hide |
| overflow | boolean | false | Move items that do not fit into a More menu |
| overflowLabel | string | "More" | Accessible name of the More button |
| layoutClassName | string | Classes for the wrapper that holds the bar and its FAB |
ToolbarButton
| Prop | Type | Default | Notes |
|---|---|---|---|
| icon | IconName | Material Symbols name | |
| label | string | required | Accessible name and tooltip |
| toggle | boolean | false | Pressed state with aria-pressed and the shape morph. Use controlled pressed if it can overflow |
| selectedIcon | IconName | Glyph shown while pressed | |
| keep | boolean | false | Stays visible when the toolbar collapses ("shrink") |
| shortcut | string | Keys shown in the tooltip | |
| ... | IconButton props | size, width, onClick, disabled, loading |
ToolbarToggleGroup, ToolbarToggleItem, ToolbarSeparator, ToolbarFab, useToolbarCollapse
| Prop | Type | Default | Notes |
|---|---|---|---|
| ToolbarToggleGroup | type="single" | "multiple" | required | Radix toggle group props. Place groups before buttons that may overflow: groups never move into the menu |
| ToolbarToggleItem | value, aria-label | required | Icon-only item; give it an aria-label |
| ToolbarSeparator | Space only, no line | ||
| ToolbarFab | FabProps | icon and label required. Color follows the toolbar. Renders beside the bar, as its own tab stop | |
| useToolbarCollapse | (ref?, { threshold }) => boolean | Collapses on scroll down, returns on scroll up. No ref follows the window |