Skip to content

headerToolbar

What the calendar’s header holds — the arrows, “today”, the title, the view buttons, your own buttons — and where; false for no header.

TypeHeaderToolbar | false
Default{ start: 'prev,next today', center: 'title', end: headerViews }
Live update (update())Yes
Declared inpackages/dom/src/calendar.ts

The header has three places: start, center and end. start and end follow the writing direction — in Arabic, start is on the right. Each place is a string of names:

  • a space separates groups: 'prev today' is two separate buttons;
  • a comma joins buttons into one group: 'prev,next' is drawn as one piece. A group of view names is the view switcher, its current view pressed.

The names:

Name What
prev, next The previous and next period
today Back to today
title The period’s title (a polite live region for screen readers)
a view’s name A button for that view: dayGridMonth, timeGridWeek, listWeek…
a key of customButtons One of your buttons
a key of headerItems A place for your own content (a menu, a filter)

false takes the header away: your application draws its own, with calendar.navigate() and calendar.kernel.getState().title — or, in the frameworks, the controller.

Without headerToolbar, the end of the header shows the views of headerViews (default: month, week, day); a single view shows no switcher.

An unknown name, or a view whose entry was not imported, is left out and said once in the console. Nothing throws.

A reload button of your own, before the views:

import { createCalendar } from '@dzcalendar/dom';
const calendar = createCalendar(element, {
timeZone: 'Europe/Paris',
headerToolbar: { start: 'title', center: '', end: 'reload today prev,next dayGridMonth,timeGridWeek' },
customButtons: {
reload: { text: 'Reload', click: () => calendar.refetch() },
},
});
// Later: no header at all.
calendar.update({ headerToolbar: false });

A button of customButtons takes text (its words and accessible name), hint (on hover; the accessible name when there is no text), icon (a class of yours, put on a hidden span before the words), click(event, element) and active (a boolean or a function: the button becomes a toggle, drawn pressed). New functions for the same buttons — a framework’s closures made at each render — are taken without redrawing the header: the button keeps the focus.

The title at the start; “today”, the arrows and the view switcher at the end.