Skip to content
satin

Toolbar

A row of buttons and toggles that is one tab stop, moved through with the arrow keys.

Installation

Terminal
npm i @uisatin/ui
Import
import { 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.

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.

PropTypeDefault
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.

KeyAction
TabMoves 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.
HomeorEndMoves to the first or last item.
EnterorSpaceRuns the focused button, or presses or releases the focused toggle.
EscCloses an open tooltip.