# Toolbar

The list-page toolbar row for a pane. Wide, search, tabs and the view switch sit inline. Narrower, tabs and views fold into a picker, then search into an icon, and the row never wraps.

Section: Components / Navigation
Page: https://ui.heyramzi.com/components/toolbar
Import path: `@heyramzi/ui/components/toolbar`

## Import

```ts
import { Toolbar } from "@heyramzi/ui/components/toolbar";
import { Button } from "@heyramzi/ui/shadcn/button";
```

## Usage

```svelte
<Toolbar bind:search bind:tab bind:view {tabs} {views}>
  {#snippet actions()}
    <button type="button">New</button>
  {/snippet}
</Toolbar>
```

## Demo

```svelte
<script lang="ts">
	import { List, SquaresFour, Plus } from "phosphor-svelte";
	import { Toolbar } from "@heyramzi/ui/components/toolbar";
	import { Button } from "@heyramzi/ui/shadcn/button";

	const tabs = [
		{ value: "all", label: "All", count: 24 },
		{ value: "open", label: "Open", count: 9 },
		{ value: "done", label: "Done", count: 15 },
	];
	const views = [
		{ value: "list", label: "List", icon: List },
		{ value: "grid", label: "Grid", icon: SquaresFour },
	];

	let search = $state("");
	let tab = $state("all");
	let view = $state("list");
</script>

<div class="flex flex-col gap-6">
	<!-- The same toolbar in two panes. It reads its own width, not the screen's. -->
	<div class="flex flex-col gap-2">
		<p class="text-xs text-muted-foreground">A 720px pane: search, tabs and view sit on the row.</p>
		<div class="w-[720px] max-w-full rounded-lg border border-border bg-card p-3">
			<Toolbar bind:search bind:tab bind:view {tabs} {views}>
				{#snippet actions()}
					<Button size="sm"><Plus aria-hidden="true" /> New</Button>
				{/snippet}
			</Toolbar>
		</div>
	</div>
	<div class="flex flex-col gap-2">
		<p class="text-xs text-muted-foreground">
			A 340px pane: the same row folded. Tabs and view open a picker, and search opens across the
			row.
		</p>
		<div class="w-[340px] max-w-full rounded-lg border border-border bg-card p-3">
			<Toolbar bind:search bind:tab bind:view {tabs} {views}>
				{#snippet actions()}
					<Button size="sm" icon aria-label="New"><Plus aria-hidden="true" /></Button>
				{/snippet}
			</Toolbar>
		</div>
	</div>
</div>
```

## API

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `search` | `string` |  | bindable. The search text. Leave it out for no search. |
| `searchPlaceholder` | `string` | `"Search..."` |  |
| `searchLabel` | `string` | `"Search"` | The label of the narrow search button. Translate at the call site. |
| `tabs` | `readonly TabDef<Tab>[]` |  | A strip of tabs, such as All, Open and Done. |
| `tab` | `Tab` |  | bindable |
| `tabsLabel` | `string` | `"Show"` |  |
| `views` | `readonly (TabDef<View> & { icon: NonNullable<TabDef<View>["icon"]> })[]` |  | How the page shows its records: a list, a board, a grid. Each one needs an icon. |
| `view` | `View` |  | bindable |
| `viewLabel` | `string` | `"View"` |  |
| `filters` | `Snippet` |  | Controls that stay on the row at every width, such as filter chips. They scroll sideways before they wrap. |
| `actions` | `Snippet` |  | The primary action and its neighbours, pinned to the right edge. |
| `class` | `string` |  |  |
