Toolbar
An accessible Shadcn toolbar with command button variants, sizes, cross-axis separators, and roving keyboard focus.
Toolbar groups related action buttons and dividers into a single accessible container with one Tab entry point and arrow-key navigation. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<wc-shadcn-toolbar-root
style-profile="rhea"
a11y-label="Document actions"
>
<wc-shadcn-toolbar-button style-profile="rhea" value="undo">
Undo
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="redo">
Redo
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-separator
style-profile="rhea"
></wc-shadcn-toolbar-separator>
<wc-shadcn-toolbar-button style-profile="rhea" value="cut">
Cut
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="copy">
Copy
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="paste"
disabled
>
Paste
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-separator
style-profile="rhea"
></wc-shadcn-toolbar-separator>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="save"
variant="default"
>
Save
</wc-shadcn-toolbar-button>
</wc-shadcn-toolbar-root>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import the prototypes directly from @proto.ui/prototypes-shadcn/toolbar and adapt them for Web Components, React, Vue 3, or Vue 2:
import { toolbarRoot, toolbarButton, toolbarSeparator } from '@proto.ui/prototypes-shadcn/toolbar';import { ShadcnToolbarRoot, ShadcnToolbarButton, ShadcnToolbarSeparator,} from '../proto-ui/components/react';
export function EditorToolbar() { return ( <ShadcnToolbarRoot styleProfile="rhea" a11yLabel="Document actions"> <ShadcnToolbarButton value="undo">Undo</ShadcnToolbarButton> <ShadcnToolbarButton value="redo">Redo</ShadcnToolbarButton> <ShadcnToolbarSeparator /> <ShadcnToolbarButton value="save" variant="default"> Save </ShadcnToolbarButton> </ShadcnToolbarRoot> );}Toolbar is composed of Root, Button, and Separator:
- Roving keyboard focus: Only one enabled
Buttonparticipates in the pageTabsequence at a time. Left/Right arrow keys navigate horizontal toolbars, Up/Down arrow keys navigate vertical toolbars, andloop={true}(default) wraps from end to start. - Command activation: Activating an enabled
Buttonemits anactionevent carrying{ value: string }. - Cross-axis divider:
Separatorautomatically aligns perpendicular toRoot’sorientation.
Style Presets (styleProfile)
Section titled “Style Presets (styleProfile)”Root, Button, and Separator support all nine Shadcn style presets (vega, nova, maia, lyra, mira, luma, sera, rhea, and new-york-v4, with new-york as a compatibility alias). When omitted or set to inherit, parts inherit from the nearest StyleScope or Root and otherwise fall back to rhea.
Examples
Section titled “Examples”Variants
Section titled “Variants”Button supports ghost (default), outline, secondary, default, and destructive variants to distinguish standard commands, primary submissions, and destructive actions inside one toolbar.
<wc-shadcn-toolbar-root
style-profile="rhea"
a11y-label="Button variants"
>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="ghost"
variant="ghost"
>
Ghost
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="outline"
variant="outline"
>
Outline
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="secondary"
variant="secondary"
>
Secondary
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-separator
style-profile="rhea"
></wc-shadcn-toolbar-separator>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="default"
variant="default"
>
Publish
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="delete"
variant="destructive"
>
Delete
</wc-shadcn-toolbar-button>
</wc-shadcn-toolbar-root>Sizes and Icon Buttons
Section titled “Sizes and Icon Buttons”Use sm, default, lg, or square icon sizes. For icon-only commands, pair an aria-hidden="true" glyph with a visually hidden sr-only label so assistive technologies announce the action clearly.
<wc-shadcn-toolbar-root
style-profile="rhea"
a11y-label="Compact formatting toolbar"
>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="bold"
size="icon"
>
<span aria-hidden="true">B</span>
<span class="sr-only">Bold</span>
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="italic"
size="icon"
>
<span aria-hidden="true">I</span>
<span class="sr-only">Italic</span>
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-separator
style-profile="rhea"
></wc-shadcn-toolbar-separator>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="comment"
size="sm"
>
Small
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="share"
size="default"
variant="outline"
>
Default
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="export"
size="lg"
variant="secondary"
>
Large
</wc-shadcn-toolbar-button>
</wc-shadcn-toolbar-root>Vertical Orientation
Section titled “Vertical Orientation”Setting orientation="vertical" stacks commands vertically, switches Separator to a horizontal rule, and maps roving keyboard navigation to Up/Down arrow keys.
<wc-shadcn-toolbar-root
style-profile="rhea"
orientation="vertical"
a11y-label="Canvas tools"
>
<wc-shadcn-toolbar-button style-profile="rhea" value="select">
Select
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="frame">
Frame
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="text">
Text
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-separator
style-profile="rhea"
></wc-shadcn-toolbar-separator>
<wc-shadcn-toolbar-button style-profile="rhea" value="zoom-in">
Zoom In
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="zoom-out">
Zoom Out
</wc-shadcn-toolbar-button>
</wc-shadcn-toolbar-root>Disabled and Non-Looping Navigation
Section titled “Disabled and Non-Looping Navigation”Setting disabled={true} on Root disables every command in the toolbar. Setting loop={false} stops arrow-key navigation at the first and last enabled commands while skipping individually disabled buttons.
<div class="grid justify-items-center gap-4">
<wc-shadcn-toolbar-root
style-profile="rhea"
disabled
a11y-label="Read-only actions"
>
<wc-shadcn-toolbar-button style-profile="rhea" value="undo">
Undo
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="redo">
Redo
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-separator
style-profile="rhea"
></wc-shadcn-toolbar-separator>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="save"
variant="default"
>
Save
</wc-shadcn-toolbar-button>
</wc-shadcn-toolbar-root>
<wc-shadcn-toolbar-root
style-profile="rhea"
loop="false"
a11y-label="Bounded actions"
>
<wc-shadcn-toolbar-button style-profile="rhea" value="back">
Back
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button
style-profile="rhea"
value="forward"
disabled
>
Forward
</wc-shadcn-toolbar-button>
<wc-shadcn-toolbar-button style-profile="rhea" value="reload">
Reload
</wc-shadcn-toolbar-button>
</wc-shadcn-toolbar-root>
</div>| Prop | Type | Default | Description |
|---|---|---|---|
styleProfile | ShadcnStyleChoice | inherit → nearest scope → rhea | Selects the Shadcn visual preset and scopes descendant toolbar parts |
variant | 'default' 'ghost' | 'default' | Framed toolbar container surface or borderless transparent layout |
disabled | boolean | false | Disables all toolbar buttons at once |
orientation | 'horizontal' 'vertical' | 'horizontal' | Layout axis and arrow-key navigation axis |
loop | boolean | true | Wraps arrow-key focus between the first and last enabled commands |
a11yLabel | string | '' | Accessible name applied to the toolbar landmark |
Button
Section titled “Button”| Prop | Type | Default | Description |
|---|---|---|---|
styleProfile | ShadcnStyleChoice | inherit → Root / scope → rhea | Overrides or inherits the enclosing Shadcn preset |
variant | 'ghost' 'outline' 'secondary' 'default' 'destructive' | 'ghost' | Visual style of the toolbar command button |
size | 'default' 'sm' 'lg' 'icon' | 'default' | Height and padding scale of the button |
value | string | '' | Command identifier emitted in the action event detail |
disabled | boolean | false | Disables this button and removes it from roving focus |
Separator
Section titled “Separator”| Prop | Type | Default | Description |
|---|---|---|---|
styleProfile | ShadcnStyleChoice | inherit → Root / scope → rhea | Aligns divider margins with compact or regular presets |
Events and Exposes
Section titled “Events and Exposes”- Button
actionevent: Emitted on enabled activation with payload{ value: string }. - Root exposes:
disabledstate andfocusFirst(),focusLast(), andsetCurrent(id)methods. - Button exposes:
disabled,focused, andfocusVisiblestates plusfocusSelf(options).