Add a toolbar UI component into Tiptap
Open source
A horizontal container for organizing related actions and controls with roving keyboard focus.
Install
You can add the primitive via Tiptap CLI
npx @tiptap/cli@latest add toolbarUsage
import { Toolbar, ToolbarGroup, ToolbarSeparator } from '@/components/tiptap-ui-primitive/toolbar'
export default function MyComponent() {
return (
<Toolbar variant="fixed">
<ToolbarGroup>
<button type="button">Bold</button>
<button type="button">Italic</button>
</ToolbarGroup>
<ToolbarSeparator />
<ToolbarGroup>
<button type="button">Format</button>
</ToolbarGroup>
<ToolbarGroup>
<button type="button">Save</button>
</ToolbarGroup>
</Toolbar>
)
}Props
Toolbar
| Name | Type | Default | Description |
|---|---|---|---|
| variant | 'fixed' | 'floating' | 'fixed' | Toolbar style variant |
| data-plain | boolean | undefined | Whether to use plain styling |
ToolbarSeparator
ToolbarSeparator renders a vertical separator between groups.
Keyboard behavior
The toolbar follows a horizontal roving-focus pattern. Disabled controls are skipped, including when their disabled state changes while the toolbar is open.
| Key | Behavior |
|---|---|
ArrowLeft, ArrowRight | Move between enabled controls and wrap at either end. |
Home, End | Move to the first or last enabled control. |
Enter | Activate the focused control. |
Space | Activate a focused native button using its standard browser behavior. |
Tab, Shift+Tab | Leave the toolbar instead of cycling through its controls. |
The toolbar does not consume Escape; an owning floating element or menu can handle that key.