DatePicker
The DatePicker component wraps react-datepicker with Payload's styles, localization, and date and time display options.
Import
Basic usage
Pair the picker with a visible label. id is applied to the picker's wrapper element, not to the underlying input, so pass the input's ID through overrides and point the label's htmlFor at that value instead:
The picker calls onChange with null when its clear button is used.
Picker appearances
Use pickerAppearance to choose between a date, date and time, day, month, or time input. Payload selects a matching display format when displayFormat is not provided.
Appearance | Input |
|---|---|
| Calendar date |
| Calendar date and time |
| Day and month |
| Month |
| Time |
Common props
These are the props most commonly used with this component. See its exported types in @payloadcms/ui for the complete list.
Prop | Type | Default | Description |
|---|---|---|---|
| | — | Sets the ID of the picker's wrapper element. |
| | — | Selected date or date string. |
| | — | Runs when the selected value changes. |
| | — | Displays text when no value is selected. |
| | | Selects the date and time controls shown. |
| | Automatic | Overrides the date-fns display format. |
| | — | Sets the earliest selectable date. |
| | — | Sets the latest selectable date. |
| | | Sets the number of visible calendar months. |
| | | Sets the number of minutes between time options. |
| | | Prevents the value from being changed. |
| | — | Passes supported options to |
Was this page helpful?