FORMS
DatePicker
Single-date picker that pairs a Memphis-styled trigger with the react-day-picker calendar inside a Popover. Locale defaults to Italian; pass any DayPicker prop through to override.
Import
Basic usage (uncontrolled)
Controlled
Manage the selection externally to react to changes (validation, persistence, syncing across fields).
Custom format
Pass any date-fns format string to formatStr.
Props
DatePicker props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | Date | — | Controlled selected date. Pair with onValueChange. |
| onValueChange | (date: Date | undefined) => void | — | Fires when the user picks a day. Receives undefined when the date is cleared. |
| placeholder | ReactNode | 'Seleziona una data' | Trigger text shown when no date is selected. |
| formatStr | string | 'PPP' | date-fns format string used for the trigger label. |
| disabled | boolean | — | Disables the trigger. |
| id | string | — | Forwarded to the trigger button (useful for label association). |
| className | string | — | Class name on the wrapper div. |
| triggerClassName | string | — | Class name on the trigger button itself. |
Native form submission
DatePicker renders a <button> + popover, not a native <input type="date">, and ships no hidden form input. To submit the value through a traditional <form>, manage the date with React state and either render your own hidden input or post the value via FormData in the submit handler.
Accessibility
- The calendar inherits
react-day-picker's ARIA wiring (grid + day cells witharia-selected). - Wrap with
FormField(or supply your own label) so the field is announced to screen readers. - Keyboard:
Space/Enteropens the popover, arrow keys navigate days,Esccloses it.