Toolbar
ツールバー
A rail of icon tools where the active one says its name. Expandable Tabs does something similar with a shared pill that slides between items; here each button animates its own padding and gap while the label grows from zero width, so the rail squeezes around the open tool and nothing travels between them — which is what lets a tool be switched off again by clicking it a second time. It is a toolbar and not a tablist, so it behaves like one: the toolbar role↗↗, a single tab stop, arrow keys and Home/End moving focus along the rail, and aria-pressed carrying the state. The demo toast and the lock toggle of the original are dropped. Adapted from Kokonut UI↗↗ under the MIT licence.
Installation
Copy and paste the following code into a new component file:1
How to use it2
Props
Toolbar
| Name | Default | Description |
|---|---|---|
| items | — | ToolbarItem[] Tools in the order they appear |
| defaultId | null | string Which tool starts pressed |
| onSelect | — | (id: string | null) => void Fired on every change, with null when the tool is switched off |
| dark | false | boolean Render the dark palette |
ToolbarItem
| Name | Default | Description |
|---|---|---|
| id | — | string Unique key |
| label | — | string Accessible name, tooltip, and the text revealed when pressed |
| icon | — | ReactNode Glyph shown at all times |