Toolbar
The header bar: a title plus structured start, center, and end regions for actions and navigation.
Live demo
Toolbar is the chrome bar that runs across the top of an app, a page, or a panel. It carries an optional heading (a plain title, or a link when given an href) and three layout regions (start, center, and end) that flex apart so leading controls sit left, primary content centers, and trailing actions push right.
It adds layout, not semantics: by default it renders a neutral <div> with no landmark role, and opts into a page-banner <header> only when you ask for it with landmark, since whether a given bar is the page banner is the consumer's call. A bare mode drops the surface fill and divider for nesting inside another container, sticky pins it to the top of its scroll area, and the size scale tightens or loosens its padding.
When to use
How this component composes with the rest of the set.
Props
6 props, straight from the manifest.
| Prop | Type | Default | Bindings | Description |
|---|---|---|---|---|
Appearance
Variants
bare
Transparent background with no divider. Chrome for nesting, not for standing alone.
sticky
Pinned to the top of its scroll area at an elevated stacking layer.
Sizes
sm
Tight, compact density.
md
Default.
lg
Roomy, generous padding.
States
title-hover
Pointer over a linked title. The title shifts to the link-hover ink.
title-focus-visible
Keyboard focus on a linked title. A token ring plus a transparent outline that becomes real in forced-colors mode.
Anatomy
The named parts that make up the component, with their selectors.
toolbar
The bar element carrying the size, sticky, and bare classes; a <div> by default, a <header> landmark when opted in.
title
The heading text; a <span>, or a focusable <a> when an href is set.
group
One of the three flex regions (start / center / end) that hold the bar's controls.
spacer
A flexible gap that pushes the content on either side of it apart.
Tokens & coverage
What the component consumes, checked live against what the algorithm produces.
Live coverage check against the xoji-default register
(derive(xojiDefault, { anchors }) →
coverComponent(manifest, register)). Every token this component
consumes must be a key the algorithm produces.
--bg-1
--border-normal
--border-thick
--border-thin
--elevation-3
--fg-0
--fg-1
--font-display
--font-sans
--leading-tight
--line
--link-hover
--radius-sm
--ring
--space-1
--space-2
--space-3
--space-4
--space-5
--space-7
--space-8
--text-lg
--weight-bold
Slots
Leading region: typically a menu trigger, logo, or back button.
Centered region: typically navigation, search, or a breadcrumb.
Trailing region: typically primary actions, pushed to the far edge.
Unstructured content placed between the heading and the center region, for bars that don't need the three named regions.
Accessibility
Code
App banner and docs bar
A landmark app header with leading icon and trailing actions, and a bare linked-title docs bar with centered nav.
<xoji-toolbar heading="Project Atlas" landmark>
<svg slot="start" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">
<path fill="currentColor" d="M3 5h18v2H3V5Zm0 6h18v2H3v-2Zm0 6h18v2H3v-2Z" />
</svg>
<span slot="end">
<xoji-button variant="ghost" tone="neutral">Settings</xoji-button>
<xoji-button variant="solid" tone="accent">Publish</xoji-button>
</span>
</xoji-toolbar>
<xoji-toolbar heading="Docs" href="/" size="sm" bare>
<nav slot="center">
<xoji-button variant="link" tone="neutral" href="/guide">Guide</xoji-button>
<xoji-button variant="link" tone="neutral" href="/api">API</xoji-button>
</nav>
</xoji-toolbar>
<script lang="ts">
import { Toolbar, Button } from "@xoji/svelte";
</script>
<Toolbar heading="Project Atlas" landmark>
{#snippet start()}
<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">
<path fill="currentColor" d="M3 5h18v2H3V5Zm0 6h18v2H3v-2Zm0 6h18v2H3v-2Z" />
</svg>
{/snippet}
{#snippet end()}
<Button variant="ghost" tone="neutral">Settings</Button>
<Button variant="solid" tone="accent">Publish</Button>
{/snippet}
</Toolbar>
<Toolbar heading="Docs" href="/" size="sm" bare>
{#snippet center()}
<Button variant="link" tone="neutral" href="/guide">Guide</Button>
<Button variant="link" tone="neutral" href="/api">API</Button>
{/snippet}
</Toolbar>
---
import { Toolbar, Button } from "@xoji/astro";
---
<Toolbar heading="Project Atlas" landmark>
<svg slot="start" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">
<path fill="currentColor" d="M3 5h18v2H3V5Zm0 6h18v2H3v-2Zm0 6h18v2H3v-2Z" />
</svg>
<Fragment slot="end">
<Button variant="ghost" tone="neutral">Settings</Button>
<Button variant="solid" tone="accent">Publish</Button>
</Fragment>
</Toolbar>
<Toolbar heading="Docs" href="/" size="sm" bare>
<nav slot="center">
<Button variant="link" tone="neutral" href="/guide">Guide</Button>
<Button variant="link" tone="neutral" href="/api">API</Button>
</nav>
</Toolbar>