Skip to content

customButtons

Buttons of your own, named in headerToolbar.

TypeReadonly<Record<string, CustomButton>>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/calendar.ts

Each key is a button’s name, to put in headerToolbar like today or a view; each value says what it is:

  • text: its words, and its accessible name.
  • hint: shown on hover; the accessible name when there is no text.
  • icon: a class of yours (an icon font, a mask) on an aria-hidden span before the words — there is no icon font of ours.
  • click(event, el): what a click does.
  • active: a boolean, or a function re-read whenever the calendar draws — the button is then a toggle (aria-pressed), drawn pressed like the current view.

A button under a built-in name (today) takes its place. A button with no click is left out, and one with neither words nor hint is named by its key — both said on the console; nothing throws. update({ customButtons }) redraws the header when a button’s words, hint, icon or toggle-ness change; new functions for the same buttons (a framework’s closures) only replace the handlers, and the focus stays.

import { createCalendar } from '@dzcalendar/dom';
let blocked = false;
const calendar = createCalendar(element, {
timeZone: 'Europe/Paris',
headerToolbar: { start: 'prev,next today', center: 'title', end: 'reload blocked' },
customButtons: {
reload: { text: 'Reload', icon: 'icon-refresh', click: () => calendar.refetch() },
// A toggle: drawn pressed while true.
blocked: { text: 'Blocked slots', active: () => blocked, click: () => { blocked = !blocked; } },
},
});

In Angular and Vue it goes in options; in React it is a prop.