DatePicker
An inline calendar that lets users select a single date. The selected date is stored internally as a YYYY-MM-DD string and dispatched via a dv-date-change custom event. Adjacent-month days are shown dimmed — clicking them navigates to that month automatically.
Default
Renders the current month with no date pre-selected.
June 2026
Su
Mo
Tu
We
Th
Fr
Sa
<DatePicker />Initial value
Pass a value string in YYYY-MM-DD format to pre-select a date and open to that month.
July 2026
Su
Mo
Tu
We
Th
Fr
Sa
<DatePicker value="2026-07-04" />Monday first
Set firstDayOfWeek={1} to start the week on Monday (ISO standard). Default is Sunday (0).
June 2026
Mo
Tu
We
Th
Fr
Sa
Su
<DatePicker firstDayOfWeek={1} />Form submission
Provide a name prop to include the selected date in a form as a hidden input. The submitted value is in YYYY-MM-DD format.
<form method="POST" action="/api/book">
<DatePicker name="date" />
<button type="submit">Book</button>
</form>Listening for changes
The dv-date-change event fires on the component's root element whenever a date is selected. event.detail.date contains the ISO string.
<DatePicker id="my-picker" />
<script>
document.getElementById('my-picker').addEventListener('dv-date-change', (e) => {
console.log('Selected:', e.detail.date) // e.g. "2026-07-04"
})
</script>Side by side
January 2026
Su
Mo
Tu
We
Th
Fr
Sa
February 2026
Mo
Tu
We
Th
Fr
Sa
Su
<Stack direction="row" gap="md" align="start">
<DatePicker value="2026-01-15" />
<DatePicker value="2026-02-20" firstDayOfWeek={1} />
</Stack>Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Initial selected date in YYYY-MM-DD format |
name | string | — | Hidden input name for form submission |
firstDayOfWeek | 0 | 1 | 0 | 0 = Sunday first, 1 = Monday first (ISO) |
Custom events
| Event | Detail | Description |
|---|---|---|
dv-date-change | { date: string } | Fires when a date is selected; date is in YYYY-MM-DD format |