Help, shown between the label and the control and read as its description.
error
ReactNode
The message for a wrong value: what is wrong and what to do. Shown beside the control.
required
boolean
Marks the field required, on the label and on the control.
announce
boolean
Announce the error as it appears (role="alert"). Set it for errors found on submit; leave it off for errors found when a field is left.
min
string
max
string
And every attribute of <input>.
Functions
Function
Signature
Does
parseDate
(text: string): Date | null
The date in 2026-11-14 (a month or day may be one digit), or null when it is not a real one.
addMonths
(d: Date, n: number): Date
The same day n months on, or the month's last day when it has fewer (31 January to 28 February).
moveDate
(d: Date, key: string, shift?: boolean): Date | null
Where a key in the grid moves the focused day (APG's table), or null for a key it ignores.
wirePicker
(group: HTMLElement): () => void
Wires one picker: group (.cap-date-picker) holds the input and the [data-cap-part="open"] button, in an input group; the dialog is added inside it. min and max (data-min, data-max on the input, as 2026-11-14) make the days outside them unchoosable.
enhance
(root?: ParentNode): () => void
Wires every [data-cap="date-picker"] under root not yet wired. Returns a function that detaches them all.
isoDate
(d: Date): string
Parts and data attributes
Class
Is
.cap-date-picker
the root
.cap-date-picker-grid
a part
.cap-date-picker-head
a part
Attribute
Values
data-date
present or absent
State
Read from
:focus-visible
the platform
:hover
the platform
[aria-current="date"]
an attribute
[aria-disabled="true"]
an attribute
[aria-selected="true"]
an attribute
Accessibility
Key
Does
Enter or Space on the calendar button
Opens the calendar, with focus on the input's date (or today)
Esc
Closes the calendar with nothing changed; focus goes back to the button
Tab, Shift Tab
Move between the month and year buttons, the grid, Cancel and Choose; focus stays in the calendar
Enter or Space on Previous or Next month, Previous or Next year
Shows that month; the focused day moves with it
Right arrow, Left arrow
The next day, the day before
Down arrow, Up arrow
The same day next week, last week
Home, End
The first day of the week (Sunday), the last (Saturday)
Page Up, Page Down
The same day last month, next month (the last day of a shorter month)
Shift Page Up, Shift Page Down
The same day last year, next year
Enter or Space on a day
Chooses it and closes the calendar; focus goes back to the button
Enter or Space on Choose
Chooses the focused day and closes the calendar
Enter or Space on Cancel
Closes the calendar with nothing changed
The calendar is a dialog named "Choose a date", opened with showModal(); the grid is a table with role="grid", named by the month heading, with a column header (abbr the full day name) for each day of the week. One day is in the Tab order at a time (roving tabindex); the chosen day has aria-selected="true", a day that cannot be chosen aria-disabled="true".
The month and year buttons are icon buttons named "Previous year", "Previous month", "Next month", "Next year"; every day and button is at least --target.
The calendar button is an icon button named "Choose date", then "Change date, " and the date.
Forced colors: the chosen day is drawn in Highlight, a day that cannot be chosen in GrayText; today keeps its underline.
Right to left: the grid follows dir; the arrows keep APG's meaning (Right arrow is the next day).