Date Picker
A custom W3C APG dialog-grid calendar component for selecting a single date. Full keyboard navigation, screen reader support, and locale-aware formatting.
Date pickers are often a huge accessibility hurdle. Our DatePicker ships the full W3C APG dialog + grid pattern with a custom calendar — no <input type="date"> — so behaviour is consistent across browsers and assistive tech.
Accessibility Features
- APG dialog + grid: The calendar is a
role="dialog"popup containing arole="grid"of date cells. Today is marked witharia-current="date", the selected cell witharia-selected="true", and cells outsideminDate/maxDatewitharia-disabled. - Grid Navigation: Arrow keys move day-by-day,
Home/Endjump to the first/last day of the week,PageUp/PageDownmove by month, andShift+PageUp/Shift+PageDownmove by year. - Focus trap: The calendar popup traps focus while open and returns it to the trigger on close — including on
Escape(withstopPropagationso it does not also close a parent dialog). - Live-region announcement: Commit (Enter / Space / click) fires a polite announcement of the selected date in the configured
locale. - Themable: Co-located
DatePicker.cssexposes CSS custom properties (--hd-datepicker-today-bg,--hd-datepicker-selected-bg,--hd-datepicker-focus-ring, …). Import via'@holmdigital/components/DatePicker.css'.
Usage Example
v0.7 BREAKING: value is now Date (was string) and onChange receives a Date object (no longer a native input event).
import { DatePicker } from '@holmdigital/components'; import '@holmdigital/components/DatePicker.css'; const [date, setDate] = useState<Date | undefined>(); <DatePicker label="Select appointment date" value={date} onChange={setDate} minDate={new Date()} locale="sv-SE" />