Forms
Date picker
Pick a date or a range from a field.
Usage
A field that looks like an input and opens the Calendar in a popover. Picking a day closes it. Inside a Field the label, hint and error wire themselves up. Here weekends and past days are blocked.
Payments run on weekdays only.
When to use
- A single date in a form: due date, birthday, delivery day.
- A start and end that belong together: a stay, a report period, a campaign — use
DateRangePicker. - Dates people know by heart or paste from elsewhere — add
typeable.
Not for: browsing a month with no field around it (use Calendar), or a date years away that is quicker to type (a birth year, say) — use typeable or a text input.
Typeable
With typeable the text can be edited. It is parsed on Enter and on blur: ISO dates, numbers in the locale’s day/month order, and month names all work. Something that is not a real date, or is outside min and max, marks the field invalid and keeps what was typed. ArrowDown opens the calendar.
Type a date (3/14/2027, Mar 14, 14 March 2027) or open the calendar. Press Enter to confirm.
Date range with presets
DateRangePicker shows two months side by side (one on phones) and a column of presets. The range commits when the second date is picked. Replace the presets with your own — each one is a label and a function of today — or pass presets={false} to hide them.
Pick your arrival and departure dates.
Apply and cancel
Add confirm for filters that reload data: the picker keeps a draft and only commits on Apply. Cancel, Esc and a click outside discard it. This one uses the default presets: Today, Yesterday, Last 7 days, Last 30 days, This month, Last month and This year.
Showing revenue for all time
In a form
Give the picker a name (or startName and endName for a range) and it submits ISO dates, yyyy-mm-dd, through hidden inputs — never a locale string.
API
DatePicker
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue | Date | null | — | Selected day. Controlled or uncontrolled. |
| onValueChange | (value: Date | null) => void | — | Called on pick, clear and typed commits. |
| open / defaultOpen / onOpenChange | boolean | — | Control the popover. |
| locale | string | 'en-US' | BCP 47 tag for the text, the calendar and typed input. |
| format | Intl.DateTimeFormatOptions | { month: "short", day: "numeric", year: "numeric" } | How the value is shown. |
| placeholder | string | 'Pick a date' | Shown while empty. |
| clearable | boolean | true | Clear button once there is a value. |
| typeable | boolean | false | Edit the date as text. |
| min / max | Date | — | Earliest and latest selectable day. |
| disabledDates | Date[] | (date: Date) => boolean | — | Days that cannot be picked or typed. |
| disabled / required | boolean | — | Also follow the surrounding Field. |
| name | string | — | Hidden input name; submits yyyy-mm-dd. |
| size | 'sm' | 'md' | 'lg' | 'md' | Height: 32 / 36 / 44px. |
| calendarProps | Pick<CalendarProps, …> | — | weekStartsOn, previousLabel, nextLabel, showOutsideDays. |
| ...props | HTMLAttributes<HTMLDivElement> | — | Forwarded to the field; ref goes to it too. |
DateRangePicker
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue | { from: Date | null; to: Date | null } | — | Selected range. |
| onValueChange | (range: DateRange) => void | — | Called when a range is committed or cleared. |
| presets | DateRangePreset[] | false | Today … This year | Shortcuts. Each is { label, range(today) }. |
| confirm | boolean | false | Apply / Cancel footer; nothing commits before Apply. |
| startName / endName | string | — | Hidden input names; submit yyyy-mm-dd. |
| placeholder | string | 'Pick a date range' | Shown while empty. |
| ... | locale, format, min, max, disabledDates, disabled, required, size, today, clearable | — | As DatePicker. |
Helpers: formatPickerDate, formatPickerDateRange, parsePickerDate and defaultDateRangePresets are exported for your own text and presets.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | On the field: open the calendar. In typeable mode, Enter commits the text. |
| Arrow Down | Open the calendar from the field. |
| Arrows, Home, End, Page Up / Down | Move around the calendar (see Calendar). |
| Enter / Space | On a day: pick it. |
| Esc | Close without changing; focus returns to the field. |
| Tab | Moves through the panel; tabbing out closes it. |
Accessibility
- The trigger is a button with aria-haspopup="dialog" and aria-expanded; its value is announced as its description.
- The panel is a non-modal dialog with a label; the calendar follows the APG date-grid pattern.
- Typed text uses aria-invalid. Clear and calendar buttons have accessible names.
- Keyboard focus shows a 3px ring on the whole field.
Motion
- The panel rises in 4px from the field with a soft blur and leaves faster.
- The field itself never scales: it opens a popup, so it answers with border and ring.
- Reduced motion: the panel only fades.