Toolbar frames related icon actions. Nest ToolbarGroup for clusters and ToolbarButton for each control. Use the end snippet for trailing actions.
Setup
<script lang="ts">
import { Toolbar, ToolbarButton, ToolbarGroup } from '.';
</script> Default
<script lang="ts">
import { Toolbar, ToolbarButton, ToolbarGroup } from '.';
</script>
<Toolbar>
<ToolbarGroup>
<ToolbarButton name="Edit" aria-label="Edit">…</ToolbarButton>
<ToolbarButton name="Duplicate" aria-label="Duplicate">…</ToolbarButton>
</ToolbarGroup>
</Toolbar> Colors
<script lang="ts">
import { Toolbar, ToolbarButton, ToolbarGroup } from '.';
</script>
<Toolbar color="primary">
<ToolbarGroup>
<ToolbarButton color="primary" aria-label="Bold">B</ToolbarButton>
</ToolbarGroup>
</Toolbar> Embedded
embedded removes the framed background so the toolbar can sit inside another surface.
<Toolbar embedded>
<ToolbarGroup>
<ToolbarButton aria-label="Cut">Cut</ToolbarButton>
<ToolbarButton aria-label="Copy">Copy</ToolbarButton>
</ToolbarGroup>
</Toolbar> End snippet
Place secondary actions on the right with {#snippet end()}.
<script lang="ts">
import { Toolbar, ToolbarButton, ToolbarGroup, Button } from '.';
</script>
<Toolbar>
<ToolbarGroup>
<ToolbarButton aria-label="Format">Format</ToolbarButton>
</ToolbarGroup>
{#snippet end()}
<Button size="xs" color="alternative">Save</Button>
{/snippet}
</Toolbar> Multiple groups
<script lang="ts">
import { Toolbar, ToolbarButton, ToolbarGroup } from '.';
</script>
<Toolbar>
<ToolbarGroup position="first">
<ToolbarButton aria-label="Align left">Left</ToolbarButton>
</ToolbarGroup>
<ToolbarGroup position="last">
<ToolbarButton color="red" aria-label="Delete">Delete</ToolbarButton>
</ToolbarGroup>
</Toolbar> As link
ToolbarButton accepts href to render as an anchor.
Props
Toolbar
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | — | Leading groups / buttons |
end | Snippet | — | Trailing content aligned to the end |
color | 'default' | 'primary' | 'secondary' | 'gray' | 'red' | 'yellow' | 'green' | 'indigo' | 'purple' | 'pink' | 'blue' | 'dark' | 'default' | Frame background / divider color |
embedded | boolean | — | Transparent, unframed toolbar |
class / classes | theme slots | — | Root / content slot overrides |
...rest | HTMLAttributes<HTMLDivElement> | — | Root attributes (color omitted from HTML) |
ToolbarGroup
| Prop | Type | Default | Description |
|---|---|---|---|
spacing | 'default' | 'tight' | 'loose' | 'default' | Gap between buttons |
padding | 'default' | 'none' | 'default' | Horizontal padding between groups |
position | 'middle' | 'first' | 'last' | — | Edge padding tweaks |
...rest | HTMLAttributes<HTMLDivElement> | — | Root attributes |
ToolbarButton
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Optional accessible name |
color | button color token | 'default' | Hover / text color |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Padding and ring size |
background | boolean | — | Dark hover background variant |
href | string | — | Render as link when set |
...rest | button or anchor attrs | — | onclick, aria-label, etc. |