DatePicker
@rockshin/tao-uiLets users enter or choose a single date, with optional time selection.
When to use
Use DatePicker when free text date input would be error-prone or when users benefit from calendar context.
Recommended
- Support keyboard entry for known dates.
- Use presets for common relative choices when helpful.
Avoid
- Do not force calendar navigation for dates far in the past without typed input.
Examples
Basic usage
Picker modes
Time, presets, and disabled dates
Date and time
showTime combines date and time selection; format the displayed parts accordingly.
Value: 2026-11-16 12:42:21
Date presets
Offer common dates through presets to reduce repeated calendar navigation.
Disable unavailable dates
Use disabledDate for business constraints. This example calculates dates locally.
Sizes and variants
Choose size and variant to match neighboring input controls.
Status and disabled state
Use error and warning for validation feedback and disabled for unavailable input.
Locale switching
TaoProvider locale updates built-in actions, placeholders, and calendar labels.
Date boundaries
minDate and maxDate constrain input and navigation; this example uses a fixed 2026 range.
Controlled value and clearing
Store changes in application state and represent a cleared picker with null.
Display format
format changes display text while values remain Dayjs objects.
Mobile date drawer
Use mobile to try the drawer on desktop and confirm the selected date.
Mobile drawer titles use mobileTitle, then the nearest Form.Item / FormField label, then localized default text. Required marks and help text are excluded; placeholders only describe the input. For standalone controls or native HTML labels, pass mobileTitle="Departure date" explicitly.
Mobile selection
Open the picker in phone mode to try selection, confirmation, and clearing inside a drawer.