Examples

Text formatting

Groups and separators organise the items; a Menu opens from inside the toolbar.

Preview
Example.tsx
import { Button, IconButton, Menu, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator } from '@reactloom/ui';
import { Bold, ChevronDown, Italic, Link, Underline, Undo2 } from 'lucide-react';

export default function Example() {
  return (
    <Toolbar aria-label="Formatting">
      <IconButton size="sm" icon={<Undo2 />} label="Undo" />
      <ToolbarSeparator />
      <ToolbarGroup aria-label="Text style">
        <ToggleButton size="sm" variant="ghost" aria-label="Bold" startIcon={<Bold />} />
        <ToggleButton size="sm" variant="ghost" aria-label="Italic" startIcon={<Italic />} />
        <ToggleButton size="sm" variant="ghost" aria-label="Underline" startIcon={<Underline />} />
      </ToolbarGroup>
      <ToolbarSeparator />
      <Menu items={[{ key: 'h1', label: 'Heading 1' }, { key: 'h2', label: 'Heading 2' }, { key: 'p', label: 'Paragraph' }]}>
        <Button size="sm" variant="ghost" endIcon={<ChevronDown />}>
          Paragraph
        </Button>
      </Menu>
      <IconButton size="sm" icon={<Link />} label="Insert link" />
    </Toolbar>
  );
}

Vertical

Up and down arrows move in a vertical toolbar.

Preview
Example.tsx
import { IconButton, Toolbar, ToolbarSeparator } from '@reactloom/ui';
import { Circle, Hand, MousePointer2, Pencil, Square, Type } from 'lucide-react';

export default function Example() {
  return (
    <Toolbar aria-label="Drawing tools" orientation="vertical" style={{ inlineSize: 'fit-content' }}>
      <IconButton size="sm" icon={<MousePointer2 />} label="Select" />
      <IconButton size="sm" icon={<Hand />} label="Pan" />
      <ToolbarSeparator />
      <IconButton size="sm" icon={<Square />} label="Rectangle" />
      <IconButton size="sm" icon={<Circle />} label="Ellipse" />
      <IconButton size="sm" icon={<Pencil />} label="Draw" />
      <IconButton size="sm" icon={<Type />} label="Text" />
    </Toolbar>
  );
}

Overflow menu

ToolbarOverflowMenu moves the items that do not fit into a More menu; hidden items leave the arrow-key order, and choosing one in the menu activates the real control. Drag the corner to narrow the box.

Preview
Example.tsx
import { Button, ToggleButton, Toolbar, ToolbarOverflowMenu, ToolbarSeparator } from '@reactloom/ui';

export default function Example() {
  return (
    // Resize the window, or narrow this box: the items that do not fit move into “More”.
    <div style={{ width: '100%', maxWidth: 360, resize: 'horizontal', overflow: 'hidden', minWidth: 160 }}>
      <Toolbar aria-label="Message">
        <Button size="sm" variant="ghost">Reply</Button>
        <Button size="sm" variant="ghost">Reply all</Button>
        <Button size="sm" variant="ghost">Forward</Button>
        <ToolbarSeparator />
        <Button size="sm" variant="ghost">Archive</Button>
        <Button size="sm" variant="ghost">Move</Button>
        <ToggleButton size="sm" variant="ghost" defaultPressed>
          Flag
        </ToggleButton>
        <ToolbarOverflowMenu />
      </Toolbar>
    </div>
  );
}

API reference

Toolbar props
PropTypeDefault
aria-label · aria-labelledbyrequired
Names the toolbar.
string—
orientation
Direction of the arrow keys and the layout.
'horizontal' | 'vertical''horizontal'
loop
Arrow keys wrap from the last item to the first.
booleantrue
wrap
Wrap items onto more lines instead of scrolling.
booleanfalse
ToolbarGroup and ToolbarSeparator
PropTypeDefault
ToolbarGroup aria-label
role="group" for related items; arrow keys pass through groups.
string—
ToolbarSeparator
role="separator", oriented across the toolbar.
—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

CSS variables

VariableDefault
--pl-toolbar-bgvar(--pl-color-bg-surface)
--pl-toolbar-border-colorvar(--pl-color-border-default)
--pl-toolbar-gapvar(--pl-space-1)
--pl-toolbar-paddingvar(--pl-space-1)
--pl-toolbar-radiusvar(--pl-radius-md)

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-orientation]horizontal · vertical
[data-wrap]present when on

Theme tokens it reads

--pl-color-bg-surface --pl-color-border-default --pl-radius-md

Accessibility

  • Only one item is in the Tab order (roving tabindex); disabled and hidden items are skipped.
  • Inside text fields, the arrow keys, Home and End keep editing the text.
  • Arrow directions follow the reading direction in right-to-left layouts.
Keyboard interactions
KeyAction
Tab / Shift+TabEnter or leave the toolbar (at the last focused item)
← → (↑ ↓ when vertical)Previous or next item, wrapping
Home / EndFirst or last item

Usage guidelines

Do

  • Group three or more related controls, as in editors and canvases.
  • Give icon-only buttons a label and show it in a Tooltip.

Don’t

  • Don’t wrap a page’s main navigation in a toolbar.
  • Don’t put a single button in a toolbar.