Toolbar
ActionsA row of controls with one Tab stop, moved through with arrow keys: <Toolbar.Root> holds Toolbar.Buttons, Toolbar.Links and Toolbar.Groups (type="single" or "multiple", bind:value) of Toolbar.GroupItems. A vertical Separator divides sections. Name it with aria-label.
import { Toolbar } from '@limerdev/zest'; Use for
Formatting and view controls above an editor, a table or a chart.
Don't
A page's main actions: use
Buttons. Navigation: use links or NavigationMenu.Examples
Basic
One Tab stop; arrow keys move through the controls. A vertical Separator divides sections.
<script lang="ts">
import AlignCenter from '@lucide/svelte/icons/align-center';
import AlignLeft from '@lucide/svelte/icons/align-left';
import AlignRight from '@lucide/svelte/icons/align-right';
import Bold from '@lucide/svelte/icons/bold';
import Italic from '@lucide/svelte/icons/italic';
import { Separator, Toolbar } from '@limerdev/zest';
let marks: string[] = $state(['bold']);
let align = $state('left');
</script>
<Toolbar.Root aria-label="Formatting">
<Toolbar.Group type="multiple" bind:value={marks} aria-label="Text style">
<Toolbar.GroupItem value="bold" aria-label="Bold"><Bold /></Toolbar.GroupItem>
<Toolbar.GroupItem value="italic" aria-label="Italic"><Italic /></Toolbar.GroupItem>
</Toolbar.Group>
<Separator orientation="vertical" class="mx-1 h-5 self-center" />
<Toolbar.Group type="single" bind:value={align} aria-label="Alignment">
<Toolbar.GroupItem value="left" aria-label="Align left"><AlignLeft /></Toolbar.GroupItem>
<Toolbar.GroupItem value="center" aria-label="Align center"><AlignCenter /></Toolbar.GroupItem>
<Toolbar.GroupItem value="right" aria-label="Align right"><AlignRight /></Toolbar.GroupItem>
</Toolbar.Group>
<Separator orientation="vertical" class="mx-1 h-5 self-center" />
<Toolbar.Button>Save draft</Toolbar.Button>
</Toolbar.Root> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Toolbar.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| loop | boolean | true | Whether or not to loop through the toolbar items when navigating with the keyboard. |
| orientation | "horizontal" | "vertical" | "horizontal" | The orientation of the toolbar. This determines how keyboard navigation will work within the toolbar. |
Toolbar.Button
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | null | false | true | – | Whether the button is disabled or not. |
Toolbar.Link
No props of its own beyond the common ones.
Toolbar.Group
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | Whether the toggle group is disabled or not. |
| onValueChange | OnChangeFn<string> | OnChangeFn<string[]> | – | |
| type required | "multiple" | "single" | – | |
| value bindable | string | string[] | – |
Toolbar.GroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | null | false | true | false | Whether the toggle item is disabled or not. |
| value required | string | – | The value of the toggle item. |