Calendar
An always-visible date-selection grid. Supports single-date and date-range selection, locale-aware day and month
names, a week start that follows locale by default (override with week-start), min/max constraints, and full
keyboard navigation. Navigation itself is min/max-aware — the prev/next month and year controls (and the "Today"
button) disable themselves once moving further would only reach a month with no selectable days left. In range
mode, presets adds a sidebar of quick-select buttons (e.g. "Last 7 days", "This month") for jumping straight to a
common range.
Playground
Switch Mode to range and turn on Sample Presets to try the presets sidebar — it's off by default (presets
itself defaults to an empty array) and seeded here only when toggled on, since it takes callback functions that
can't be expressed as an HTML attribute like the rest of this Playground's controls.
Usage
<!-- Basic -->
<lt-calendar></lt-calendar>
<!-- Pre-selected date -->
<lt-calendar value="2026-06-15"></lt-calendar>
<!-- Date range selection -->
<lt-calendar mode="range" value-start="2026-06-01" value-end="2026-06-15"></lt-calendar>
<!-- Two-month view -->
<lt-calendar months="2"></lt-calendar>
<!-- Two-month range picker -->
<lt-calendar mode="range" months="2"></lt-calendar>
<!-- With min/max range -->
<lt-calendar min="2026-01-01" max="2026-12-31"></lt-calendar>
<!-- French locale — week start follows the locale automatically (Monday) -->
<lt-calendar locale="fr-FR"></lt-calendar>
<!-- French locale, but force a Sunday start -->
<lt-calendar locale="fr-FR" week-start="0"></lt-calendar>
<!-- With ISO 8601 week numbers -->
<lt-calendar show-week-numbers></lt-calendar>
import { Calendar } from '@latty-ds/react';
// Basic
<Calendar />
// Pre-selected date
<Calendar value="2026-06-15" />
// Date range selection
<Calendar mode="range" valueStart="2026-06-01" valueEnd="2026-06-15" />
// Two-month view
<Calendar months={2} />
// Two-month range picker
<Calendar mode="range" months={2} />
// With min/max range
<Calendar min="2026-01-01" max="2026-12-31" />
// French locale — week start follows the locale automatically (Monday)
<Calendar locale="fr-FR" />
// French locale, but force a Sunday start
<Calendar locale="fr-FR" weekStart="0" />
// With ISO 8601 week numbers
<Calendar showWeekNumbers />
<template>
<!-- Basic -->
<lt-calendar></lt-calendar>
<!-- Pre-selected date -->
<lt-calendar value="2026-06-15"></lt-calendar>
<!-- Date range selection -->
<lt-calendar mode="range" value-start="2026-06-01" value-end="2026-06-15"></lt-calendar>
<!-- Two-month view -->
<lt-calendar :months="2"></lt-calendar>
<!-- Two-month range picker -->
<lt-calendar mode="range" :months="2"></lt-calendar>
<!-- With min/max range -->
<lt-calendar min="2026-01-01" max="2026-12-31"></lt-calendar>
<!-- French locale — week start follows the locale automatically (Monday) -->
<lt-calendar locale="fr-FR"></lt-calendar>
<!-- French locale, but force a Sunday start -->
<lt-calendar locale="fr-FR" week-start="0"></lt-calendar>
<!-- With ISO 8601 week numbers -->
<lt-calendar show-week-numbers></lt-calendar>
</template>
disabledDates (a JS-only property, since it can take a function) disables individual dates beyond min/max —
either a fixed list, or a predicate for a rule impractical to enumerate:
// A fixed list
calendar.disabledDates = [new Date(2026, 5, 19)];
// A rule — every weekend, in this example
calendar.disabledDates = (date) => date.getDay() === 0 || date.getDay() === 6;
presets (a JS-only property, mode="range" only) adds a sidebar of quick-select range buttons. Each preset's
getRange() is called fresh on every click, so a "Last 7 days"-style preset stays correct relative to today even if
the calendar is left open across a day boundary:
calendar.mode = 'range';
calendar.presets = [
{
label: 'Last 7 days',
getRange: () => {
const end = new Date();
const start = new Date();
start.setDate(start.getDate() - 6);
return [start, end];
}
},
{
label: 'This month',
getRange: () => {
const now = new Date();
return [new Date(now.getFullYear(), now.getMonth(), 1), new Date(now.getFullYear(), now.getMonth() + 1, 0)];
}
}
];