Date range picker with presets
Two clicks pick a first and a last day, in any order. Ready-made periods sit beside the calendar. The value is two ISO dates, both included.
The code
import { createDatePicker } from '@nervure/datetime';
createDatePicker('#field', {
mode: 'range',
presets: true,
onChange: (selection) => console.log(selection.value, selection.start, selection.end),
});The value is { start: '2026-12-01', end: '2026-12-14' }. Read the guide for every option, and see every example.
What it does
- Thirteen ready-made periods, counted from today in the time zone, and your own.
- One to three months side by side (
months), or stacked (orientation: 'vertical'). - The days between the two ends are shown while the pointer moves.
min,maxanddisableclose days: a closed day cannot be picked.
Why this one
- No dependency, about 18 kB gzipped for every mode, zone and language.
- Values are ISO 8601 text. Each selection also gives two instants,
startandend, in the time zone. - 28 languages and right to left. Keyboard and screen readers.
- Your CSS and your colours, through CSS variables. Light and dark.
- The same picker in plain JavaScript, as a web component, in React and in Vue.