Toolbar
A row of buttons and toggles that is one tab stop, moved through with the arrow keys.
Installation
npm i @uisatin/uiimport { Toolbar, ToolbarButton, ToolbarSeparator, ToolbarToggle } from '@uisatin/ui/toolbar'About 41.8 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/toolbar.json https://uisatin.dev/r/floating.jsonAdds toolbar.tsx, button.tsx, button-group.tsx, dropdown.tsx, floating.tsx, kbd.tsx, labels.tsx, pointer-modality.tsx, spinner.tsx, toggle.tsx and tooltip.tsx to components/ui and installs radix-ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The Toolbar component is a div with role="toolbar" on the Radix toolbar: one tab stop, the arrow keys move between its items. Name it with aria-label. ToolbarButton is a tertiary Button and ToolbarToggle a ghost Toggle (pressed / defaultPressed / onPressedChange), both at the toolbar's size; with an icon and no children they are icon-only, named by label, which their tooltip shows with shortcut as keys. ToolbarSeparator is a rule between sets. variant="floating" puts it on the menu surface, for a bubble bar placed with Floating over a selection; preventFocusOnPress keeps a press from taking focus from an editor.
| Prop | Type | Default |
|---|---|---|
aria-label | string | — |
variant | "plain""floating" | "plain" |
size | "sm""md" | "sm" |
orientation | "horizontal""vertical" | "horizontal" |
loop | boolean | true |
dir | "ltr""rtl" | — |
preventFocusOnPress | boolean | false |
className | string | — |
ref | Ref<HTMLElement> | — |
...props | ComponentProps<typeof Toolbar.Root>Other attributes go to the Radix Toolbar.Root part | — |
Accessibility
A Radix toolbar: a div with role="toolbar" and aria-orientation; give it an aria-label ("Formatting"). It is one tab stop and remembers the item focused last. ToolbarToggle is a button with aria-pressed; keep its label the same pressed or not. An icon-only item is named by label and shows it in a tooltip on hover and keyboard focus, with shortcut as keys and as aria-keyshortcuts. ToolbarSeparator is a separator across the toolbar. Disabled items are skipped by the arrows. With preventFocusOnPress, a pointer press leaves focus (and an editor's selection) where it was; the keyboard still reaches every item.
| Key | Action |
|---|---|
| Tab | Moves focus into the toolbar, to the item focused last, and out of it. |
| →or← | Moves to the next or previous item, wrapping at the ends; right to left, the arrows flip. ↓ and ↑ when vertical. |
| HomeorEnd | Moves to the first or last item. |
| EnterorSpace | Runs the focused button, or presses or releases the focused toggle. |
| Esc | Closes an open tooltip. |
Something wrong or missing on this page?
Report a problemSuggest an improvement