Skip to main content

toolbar

Configures the toolbar rendered above the calendar grid. Replaces the default item list, adds a CSS class to the toolbar container, or hides the toolbar entirely when set to null.

Usage

toolbar?: { items?: ToolbarItem[]; css?: string } | null;
FieldTypeDescription
itemsToolbarItem[]Replaces the default toolbar item list. Omit to keep the default layout.
cssstringExtra CSS class applied to the toolbar container.

ToolbarItem:

FieldTypeDescription
idstringIdentifier referenced by exec("action", { id }) and routing.
compstringComponent to render. Built-in: "dateNav", "todayButton", "spacer", "dateLabel", "richselect", "segmented", "addEventButton", "menuButton". Custom names also allowed.
valueanyInitial value for input-like items.
options{ id: string; label: string }[]Option list for selector-type items.

Default value: undefined - renders the default toolbar (getToolbarItems()):

[
{ id: "nav", comp: "dateNav" },
{ id: "today", comp: "todayButton" },
{ comp: "spacer" },
{ id: "title", comp: "dateLabel" },
{ comp: "spacer" },
{ id: "modes", comp: "richselect" },
{ id: "add-event", comp: "addEventButton" },
];

When readonly is true, items with comp: "addEventButton" are filtered out automatically.

Example

Custom item list:

<script>
import { Calendar, getToolbarItems } from "@svar-ui/svelte-calendar";

const toolbar = {
items: [
...getToolbarItems(),
{ id: "export", comp: "button", text: "Export" },
],
css: "my-toolbar",
};
</script>

<Calendar {toolbar} events={[]} date={new Date()} />

Hide the toolbar:

<Calendar toolbar={null} events={[]} date={new Date()} />
  • getToolbarItems — fresh copy of the default item list.
  • action — fired by menuButton and custom toolbar buttons.
  • readonly — strips addEventButton from the toolbar.
  • Navigation bar — full toolbar customization guide.