DatePicker
A field-like trigger that opens Calendar in a popover, with localized formatting and form support.
react-day-picker reference ↗Installation
Run it from the root of a project already set up with zunoui init.
npx zunoui@latest add date-pickerDependencies
What add date-picker installs alongside the component. The CLI skips any you already have in a compatible version.
ZUNO registry
@zuno/utils@zuno/popover@zuno/calendar
Examples
4 examples · 1 componentWith a label
The visible label names the trigger; picking a date closes the popover.
Date range
Two months side by side; it closes once both ends are chosen.
Form with help and error
Submits YYYY-MM-DD through name; help and error text are linked with aria-describedby.
Localized
Spanish locale for the calendar and a long Intl format in the trigger.
API reference
Keeps the props of react-day-picker, plus ZUNO's styles; the table lists the ones you use most.
| Prop | Type | Default |
|---|---|---|
value / defaultValueSelected date, controlled or uncontrolled. | Date | — |
onValueChangeCalled on select; the popover closes after a date is chosen. | (date?: Date) => void | — |
nameSubmits YYYY-MM-DD through a hidden input for native forms (DatePicker only). | string | — |
placeholderTrigger text when empty. | string | "Pick a date" |
localedate-fns locale from react-day-picker/locale; used by the calendar and the trigger text. | Locale | en-US |
formatOptionsHow the trigger shows the date. | Intl.DateTimeFormatOptions | { dateStyle: "medium" } |
calendarPropsPassed to Calendar: disabled, startMonth, endMonth, numberOfMonths… | DayPickerProps | — |
aria-invalid / aria-describedbyError state and the id of help or error text. | boolean / string | — |
DateRangePickerSame API for ranges; two months, closes when both ends are set and shows the range with Intl formatRange. | value: DateRange | — |
States
The states that apply to this component and their visual treatment.
| State | Treatment |
|---|---|
| Empty | Muted placeholder text. |
| Filled | The date formatted with Intl in the given locale. |
| Open | Calendar in a popover, focused on the selected day or today. |
| Range in progress | Shows "start – …" until the end is chosen. |
| Invalid | aria-invalid paints the border destructive; pair it with an error message. |
| Disabled | Dimmed; the popover does not open. |
Accessibility
The trigger is a button labelled by its Label (htmlFor/id) and announces the chosen date as its text; it exposes aria-expanded and aria-haspopup.
Opening moves focus into the calendar grid on the selected day or today; choosing a date closes the popover and returns focus to the trigger. Escape closes without changes.
Point aria-describedby at the format help or the error message and set aria-invalid when it fails, so both are announced with the field.
The popover is labelled "Choose a date"; everything inside follows Calendar's keyboard model.