Skip to Content
NarakUI

Toolbar

A row of related controls that the keyboard reaches as one stop and moves through with the arrow keys.

Formatting toolbar

Wrap each control in Toolbar.Item. Tab moves focus into the toolbar once, and the left and right arrow keys move between items, wrapping at the ends. Toolbar.Separator divides groups of actions.

Pass disabled to Toolbar.Item rather than to the button inside it, so the arrow keys skip the item. For on and off controls, set aria-pressed on the button.

Bulk actions

Toolbar.Root is unstyled apart from a small gap, so it can sit on any surface. Here it fills a Card that appears while table rows are selected. Plain text, such as the selection count, can sit between items without joining the arrow-key sequence.

With a text field

Toolbar.Field adds an Input to the arrow-key sequence. While the field has focus, the left and right arrow keys move the caret first and only leave the field from its start or end.

Installation

pnpm dlx shadcn@latest add @narakui/toolbar

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/toolbar.json.

Usage

import { Button } from '@/components/ui/button';
import { Toolbar } from '@/components/ui/toolbar';

<Toolbar.Root aria-label="Slide editing">
  <Toolbar.Item>
    <Button mode="ghost" iconStart="arrow-left" aria-label="Undo" onClick={undo} />
  </Toolbar.Item>
  <Toolbar.Separator />
  <Toolbar.Item disabled={!canRedo}>
    <Button mode="ghost" iconStart="arrow-right" aria-label="Redo" onClick={redo} />
  </Toolbar.Item>
</Toolbar.Root>;

Toolbar.Root Properties

PropTypeDefaultDescription
aria-labelstring—Accessible name of the toolbar, such as Text formatting
orientation'horizontal' | 'vertical''horizontal'Which arrow keys move focus. It does not change the layout
loopbooleantrueWhether arrow-key focus wraps from the last item to the first
dir'ltr' | 'rtl'—Reading direction used for left and right arrow keys
classNamestring—Additional classes for the toolbar. Other div props are passed through

Toolbar.Item Properties

PropTypeDefaultDescription
childrenReactElementRequiredA single button-like element, usually a Button. It receives the toolbar's focus handling
disabledbooleanfalseDisables the child and removes it from the arrow-key sequence

Toolbar.Field Properties

PropTypeDefaultDescription
childrenReactElement<InputProps>RequiredA single Input. Its own focus, blur and key handlers still run
disabledbooleanfalseRemoves the field from the arrow-key sequence

Toolbar.Separator Properties

PropTypeDefaultDescription
classNamestring—Additional classes for the vertical divider, such as a taller h-6 next to regular buttons