Skip to main content

Overview

Toolbar provides a container for grouping related controls like buttons, toggle buttons, dropdown menus, and links. It supports keyboard navigation and proper focus management.

Features

  • Full keyboard navigation
  • Supports horizontal/vertical orientation
  • Flexible layout support
  • Can contain buttons, links, separators, and toggle groups
  • Focus management with roving tabindex
  • Proper ARIA attributes for accessibility

Installation

Anatomy

API Reference

Root

Contains all the toolbar component parts.
'horizontal' | 'vertical'
default:"'horizontal'"
The orientation of the toolbar.
'ltr' | 'rtl'
The reading direction of the toolbar. If omitted, inherits from the parent.
boolean
default:"true"
When true, keyboard navigation will loop from last item to first, and vice versa.
boolean
default:"false"
Change the default rendered element for the one passed as a child.

Button

A button item.
boolean
When true, prevents the user from interacting with the button.
boolean
default:"false"
Change the default rendered element for the one passed as a child.
A link item.
boolean
default:"false"
Change the default rendered element for the one passed as a child.

ToggleGroup

A set of two-state buttons that can be toggled on or off.
'single' | 'multiple'
required
Determines whether a single or multiple items can be pressed at a time.
When type="single":
string
The controlled value of the pressed item.
string
The value of the item to show as pressed when initially rendered (uncontrolled).
(value: string) => void
Event handler called when the pressed state changes.
When type="multiple":
string[]
The controlled value of the pressed items.
string[]
The values of the items to show as pressed when initially rendered (uncontrolled).
(value: string[]) => void
Event handler called when the pressed state changes.
Common props:
boolean
When true, prevents the user from interacting with the toggle group and all its items.
boolean
default:"true"
When false, prevents automatic focus cycling through items.
'horizontal' | 'vertical'
default:"'horizontal'"
The orientation of the component.
'ltr' | 'rtl'
The reading direction of the toggle group.
boolean
default:"true"
When loop and rovingFocus are true, keyboard navigation will loop.

ToggleItem

An item in the toggle group.
string
required
A unique value for the item.
boolean
When true, prevents the user from interacting with the item.
boolean
default:"false"
Change the default rendered element for the one passed as a child.

Separator

Used to visually separate items in the toolbar.
boolean
default:"false"
Change the default rendered element for the one passed as a child.

Example

Accessibility

Uses roving tabindex to manage focus movement among items.

Keyboard Interactions

  • Tab - Moves focus to the first item in the toolbar.
  • ArrowRight - Moves focus to the next item in the toolbar (in horizontal orientation).
  • ArrowLeft - Moves focus to the previous item in the toolbar (in horizontal orientation).
  • ArrowDown - Moves focus to the next item in the toolbar (in vertical orientation).
  • ArrowUp - Moves focus to the previous item in the toolbar (in vertical orientation).
  • Home - Moves focus to the first item.
  • End - Moves focus to the last item.