Toolbar
A row of controls with one tab stop: Tab reaches the toolbar, the arrow keys move between its buttons, Home and End jump to the ends. Built on ui-sdk's Toolbar. Icon buttons show their label as a tooltip; pressed makes a button a toggle. The Rich text field's toolbar is this one.
BetaReady to use. Its API can still change in a minor release; the changelog says when.
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "@leap-crm/design-system";Playground
Change a prop and the component follows. Its code is under Props.
Props
Best practices
When to use it, and the rules that apply in particular places.
| Guidance | Practice |
|---|---|
| Do | Use it for a row of related commands that should be one tab stop, like the rich text field's formatting buttons. |
| Do | Name it with aria-label, like Formatting, and give every ToolbarButton a label. An icon-only button shows its label as a tooltip. |
| Do | Pass shortcut when the command has one, like mod+b for Bold, so the tooltip shows it. |
| Do | Split related commands with ToolbarGroup and ToolbarSeparator, like text styles and lists. Set pressed on a button that toggles, like Bold. |
| Don't | Use it for two or three standalone actions, like Export as CSV or PDF. Use ButtonGroup, where each button is its own tab stop. |
Props
Toolbar
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label * | string | — | Names the toolbar, like "Formatting". |
| children | ReactNode | — | What it shows inside. |
| className | string | — | Classes added to the root element, merged with its own. Tokens only. |
ToolbarButton
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | ReactNode | — | The 14 px icon. With no children, the button is icon only. |
| label * | string | — | Names the button. An icon-only button also shows it as its tooltip. |
| children | ReactNode | — | Visible text after the icon. |
| pressed | boolean | — | Makes it a toggle that stays pressed, like Bold. |
| shortcut | string | — | A keyboard shortcut for the tooltip, like "mod+b". |
| onClick | () => void | — | Runs the command. |
| disabled | boolean | — | Shows it as unavailable and stops it responding. |
| className | string | — | Classes added to the root element, merged with its own. Tokens only. |
ToolbarGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Classes added to the root element, merged with its own. Tokens only. |
ToolbarSeparator
No props of its own.
Code
What the playground shows, ready to copy.
import { PlusIcon, Toolbar, ToolbarButton } from "@leap-crm/design-system";
<Toolbar aria-label="Formatting">
<ToolbarButton label="Bold" icon={<PlusIcon />} />
</Toolbar>Formatting
Two groups of toggles split by a rule. Tab in, then use the arrow keys; Bold, Italic and Underline toggle.
With text
A button with children shows its text and needs no tooltip.
What the examples share
The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.
import { AlignCenter, AlignLeft, AlignRight, Bold, Download, Italic, Printer, Underline } from "lucide-react";
import { useState } from "react";
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "@leap-crm/design-system";
const alignments = [
{ value: "left", icon: <AlignLeft /> },
{ value: "center", icon: <AlignCenter /> },
{ value: "right", icon: <AlignRight /> },
];
function Formatting() {
const [marks, setMarks] = useState<string[]>(["bold"]);
const [align, setAlign] = useState("left");
const toggle = (mark: string) =>
setMarks(current =>
current.includes(mark)
? current.filter(m => m !== mark)
: [...current, mark],
);
return (
<Toolbar
aria-label="Formatting"
className="border-neutral-border w-fit rounded-md border p-1"
>
<ToolbarGroup aria-label="Text style">
<ToolbarButton
icon={<Bold />}
label="Bold"
shortcut="mod+b"
pressed={marks.includes("bold")}
onClick={() => toggle("bold")}
/>
<ToolbarButton
icon={<Italic />}
label="Italic"
shortcut="mod+i"
pressed={marks.includes("italic")}
onClick={() => toggle("italic")}
/>
<ToolbarButton
icon={<Underline />}
label="Underline"
shortcut="mod+u"
pressed={marks.includes("underline")}
onClick={() => toggle("underline")}
/>
</ToolbarGroup>
<ToolbarSeparator />
<ToolbarGroup aria-label="Alignment">
{alignments.map(({ value, icon }) => (
<ToolbarButton
key={value}
icon={icon}
label={`Align ${value}`}
pressed={align === value}
onClick={() => setAlign(value)}
/>
))}
</ToolbarGroup>
</Toolbar>
);
}Keyboard
The keys it answers to. Tab moves between components, arrows move within them.
| Keys | What they do |
|---|---|
| Tab | Lands on the toolbar once, on the item focused last, and Tab again leaves it. |
| ArrowRightArrowLeft | Move through every item, wrapping at the ends. |
| EnterSpace | Press the focused item. Arrow keys never press a toggle. |





