Skip to content

selectable

Lets a person select a stretch of empty time — to book it, to block it.

Typeboolean
Defaultfalse
Live update (update())Yes
Declared inpackages/dom/src/settings.ts

With selectable: true, dragging across empty time selects it: hours in a time grid, days in a month. On the keyboard, Enter on a slot selects it and Shift+arrows grow it (said as it grows); Enter gives it to the application.

onSelect(selection) hears it: { start, end, allDay, resourceId? }, the start and end in the calendar’s zone (ZonedDateTimes), or dates for whole days — the end then the day after the last one. On a touch screen, a tap on empty time selects one slot, with handles to stretch it. Enter (or Space) on a slot is also a date click. The selection stays drawn until a click elsewhere, Escape or another period (onUnselect); calendar.select(selection | null) shows or clears one from your code. A mouse click does not select: a click is a date click (onDateClick).

import { createCalendar } from '@dzcalendar/dom';
createCalendar(element, {
timeZone: 'Europe/Paris',
selectable: true,
onSelect: ({ start, end }) => console.log(`book ${start.toString()} → ${end.toString()}`),
});

In the frameworks it is an input: Angular’s selectable (and the two-way [(selection)]), React’s selectable (with selection and onSelectionChange), Vue’s selectable (with v-model:selection).

Drag across empty hours to select them.