getToolbarItems
Builds the default item array for the Toolbar component. Items are returned in a fixed order: add-card button, undo/redo buttons, sort menu. Pass the result to <Toolbar :items="...">, or mutate it before passing to customize the bar.
Usage
import { getToolbarItems } from "@svar-ui/vue-kanban";
import type { ToolbarButtonConfig } from "@svar-ui/vue-kanban";
function getToolbarItems(config?: ToolbarButtonConfig): any[];
type ToolbarButtonConfig = {
add?: boolean;
undo?: boolean;
sort?: boolean;
};
| Field | Type | Description |
|---|---|---|
add | boolean | Include the add-card primary button and a separator |
undo | boolean | Include undo and redo icon buttons |
sort | boolean | Include a collapsed sort menu (label, priority, and clear) |
Returned items by group:
| Group | Item ids |
|---|---|
| add | add-card, separator |
| undo | undo, redo |
| sort | sort-label-asc, sort-label-desc, sort-priority-asc, sort-priority-desc, separator, sort-clear |
Items with built-in ids (add-card, undo, redo, sort-clear, etc.) get their click handlers wired automatically by the Toolbar component. Custom items without a handler and without a matching id are click-inert.
Example
Default set with all groups:
const items = getToolbarItems({ add: true, undo: true, sort: true });
Just the add button:
const items = getToolbarItems({ add: true });
Customize one entry before passing to <Toolbar>:
<script setup>
import { Toolbar, getToolbarItems } from "@svar-ui/vue-kanban";
const items = getToolbarItems({ add: true, sort: true });
// replace the first sort entry with a custom one
const sortMenu = items.find(it => it.collapsed);
sortMenu.items[0] = {
id: "sort-deadline-asc",
comp: "item",
text: "Deadline (soonest)",
handler: () =>
api.exec("sort-cards", {
sort: { field: "deadline", dir: "asc" },
}),
};
</script>
<template>
<Toolbar :api="api" :items="items" />
</template>
Related
- Toolbar guide - mounting and customizing the toolbar
- Toolbar - the component that renders these items