Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Structure

Toolbar

Groups related controls into one named bar with a single Tab stop, following the WAI-ARIA toolbar pattern. Arrow keys move between the controls. For one standalone action, use Button.

One tab stop arrows home end

When to useLink to "When to use"

  • Three or more related controls in a row: editor actions, tree actions, table headers, popup chrome.
  • Mixed controls that should share one Tab stop (buttons, a SegmentedControl, a search field).

Use something else when:

  • you have one or two actions: place Buttons directly
  • the controls are page navigation: links in a navigation landmark

UsageLink to "Usage"

tsx
Copy
import { IconButton, SearchField, SegmentedControl, Toolbar } from "@arshad-shah/cynosure";
import { code, edit, tree } from "@arshad-shah/cynosure/icons";

<Toolbar label="Document actions">
  <IconButton icon={edit} label="Edit" />
  <SegmentedControl
    label="View"
    defaultValue="tree"
    options={[
      { value: "tree", label: "Tree", icon: tree },
      { value: "raw", label: "Raw", icon: code },
    ]}
  />
  <SearchField label="Search" labelHidden />
</Toolbar>

label is required: a toolbar must have an accessible name.

Fields in a toolbarLink to "Fields in a toolbar"

Text fields keep their own arrow, Home and End keys, so typing still works. Fields sit level with the buttons.

Fields sit level with buttons

Vertical toolbarsLink to "Vertical toolbars"

Set orientation="vertical" to use Up and Down instead of Left and Right.

Vertical uses up and down

loop (default true) wraps from the last control to the first. Set loop={false} to stop at the ends.

PropsLink to "Props"

Every prop of Toolbar
PropWhat it doesTypeDefault
labelRequired
Accessible name (required: a toolbar must be named).string
orientation
Direction of the toolbar: Left/Right move between controls, or Up/Down when vertical. Default "horizontal"."horizontal" | "vertical""horizontal"
loop
Arrow keys wrap from the last item to the first.boolean
className
Added to the root element, for layout.string
style
Layout only.CSSProperties
children
Buttons, IconButtons, SegmentedControls, fields.ReactNode
data-testid
Test id, set on the toolbar element.string

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

Behaviour and accessibility, table 1
InputResult
TabEnters the toolbar on one control, then leaves it. Returning lands on the last focused control
Left and Right arrowsMove focus (flipped in right-to-left layouts)
Up and Down arrowsMove focus in a vertical toolbar
Home, EndJump to the first or last control
  • Disabled controls are skipped.
  • Radios inside (SegmentedControl) are separate stops: arrows move focus and Space selects, as in the APG toolbar pattern.
  • Late additions: controls added after render join the group automatically.
  • Role: role="toolbar" with aria-label and aria-orientation.

ThemingLink to "Theming"

Tokens: --cy-toolbar-gap and --cy-toolbar-padding.

ts
Copy
createTheme({ components: { toolbar: { gap: "4px", padding: "6px" } } });

className and style are for layout only.

Button · IconButton · SegmentedControl · SearchField

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog