Skip to main content

Toolbar

Board-level button bar that wires add-card, undo/redo, and sort actions to the Kanban store. Wraps @svar-uisvelte-toolbar with kanban-specific defaults: localized labels, reactive history-based disable for undo/redo, and a built-in click handler that routes known item ids to api.exec(...).

Usage

import { Toolbar } from "@svar-uisvelte-kanban";
<Toolbar {api} />

Props

PropTypeDefaultDescription
apiKanbanInstanceApi | nullnullKanban instance for click handlers and history state
itemsany[][]Explicit item array; replaces the default set when non-empty
addbooleantrueShow the add-card primary button and separator
undobooleanfalseShow undo/redo icon buttons; auto-disabled from history state
sortbooleanfalseShow the collapsed sort menu (label/priority asc/desc, clear)

When items is non-empty, the add, undo, and sort props are ignored. Items with a built-in id (add-card, undo, redo, sort-clear, etc.) keep their default click handler unless the item provides its own handler.

Default item ids

Item idAction dispatchedGroup
add-cardexec("add-card", { card: {}, edit: true })add
undoexec("undo", {})undo
redoexec("redo", {})undo
sort-label-ascexec("sort-cards", { sort: { field: "label", dir: "asc" } })sort
sort-label-descexec("sort-cards", { sort: { field: "label", dir: "desc" } })sort
sort-priority-ascexec("sort-cards", { sort: { field: "priority", dir: "asc" } })sort
sort-priority-descexec("sort-cards", { sort: { field: "priority", dir: "desc" } })sort
sort-clearexec("sort-cards", { sort: null })sort

Example

Minimal toolbar with the add button (default):

<script>
import { Kanban, Toolbar } from "@svar-uisvelte-kanban";
let api = $state();
</script>

<Toolbar {api} />
<Kanban {cards} {columns} init={a => (api = a)} />

Full default set with undo/redo and sort:

<Toolbar {api} undo sort />
<Kanban {cards} {columns} history init={a => (api = a)} />

Custom items replacing the defaults:

<script>
import { Kanban, Toolbar, getToolbarItems } from "@svar-uisvelte-kanban";

let api = $state();

const items = [
...getToolbarItems({ add: true }),
{
id: "sort-deadline",
comp: "item",
text: "Deadline",
handler: () => api.exec("sort-cards", {
sort: { field: "deadline", dir: "asc" },
}),
},
];
</script>

<Toolbar {api} {items} />
<Kanban {cards} {columns} init={a => (api = a)} />