Date picker
Select a single date from a calendar with month and year dropdowns. For a start and end together use Date range picker.
Purpose
A field that opens a calendar. Month and year dropdowns matter more than they look: without them, picking a date of birth means dozens of clicks. For a start and end together use Date range picker.
Example
With a label
The id prop is forwarded to the trigger button, so a Label pairs with it exactly as it would
with an input. The picker is controlled — hold the date in state:
const [date, setDate] = React.useState<Date | undefined>();
<div className="grid w-64 gap-1.5">
<Label htmlFor="dob">Date of birth</Label>
<DatePicker id="dob" value={date} onChange={setDate} placeholder="Select a date" />
</div>States
Empty and selected. The empty trigger shows the placeholder in --muted-foreground; a selection
renders as a long-form date. There is no disabled state — DatePickerProps exposes no disabled,
so omit the control or render the value as text when it cannot be changed.
Structure
| Property | Value |
|---|---|
| Trigger | outline Button, 40px (h-10), full width, left-aligned |
| Trigger icon | 18px calendar_month glyph, --muted-foreground |
| Placeholder | --muted-foreground |
| Popover | --popover surface, --radius-lg, --shadow-8, zero padding |
| Day cells | 40px square (size-10), --radius-md |
| Selected day | --primary fill, --primary-foreground text |
| Today | 1px --primary border ring |
| Value format | date-fns PPP — "6th August 2026" |
Best practices
Do
- Pair the trigger with a
Labelvia theidprop — a calendar icon is not a label. - Rely on the month and year dropdowns for far-off dates — they are the default caption.
- Use the
placeholderto say which date is wanted ("Select a start date").
Don't
- Use two single pickers for a span — that is Date range picker.
- Leave the default "Pick a date" placeholder when the field means something specific.
- Reach for a picker when free typing is faster and the format is unambiguous — consider an Input with validation for well-rehearsed dates.
Accessibility & keyboard
- The trigger is a real button announcing the current value (or placeholder); pair it with a
Labelviaidso the field itself is named. - When the popover opens, focus deliberately moves into the calendar grid (the source
autoFocusis required — without it keyboard users are stranded on the trigger). - The month and year dropdowns are native
<select>elements with their own accessible names. - Choosing a date closes the popover and returns focus to the trigger.
- Keyboard: Enter or Space on the trigger opens the calendar; arrow keys move a day (up/down a week) at a time in the grid; Enter or Space selects and closes; Esc closes without selecting.
Props
DatePicker is controlled: pass value and handle onChange, which fires with the new date or
undefined when the selection is cleared.
| Prop | Type | Default | Description |
|---|---|---|---|
value | Date | undefined | — | The currently selected date (controlled). |
onChange | ((date: Date | undefined) => void) | undefined | — | Called with the new date, or `undefined` when the selection is cleared. |
placeholder | string | undefined | "Pick a date" | Trigger text shown when no date is selected. |
id | string | undefined | — | `id` forwarded to the trigger button, for pairing with a `<Label htmlFor>`. |
className | string | undefined | — | — |