Date Picker
A Calendar in a Popover, with a trigger whose label cross-fades as you pick. Comes with a range variant and smart presets.
Inputs
Pick the day you ship.
Playground
Tweak the props, the preview and the code follow.
Props
import { DatePicker } from "@/components/ui/date-picker"
<DatePicker
value={value}
onChange={setValue}
placeholder="Pick a date"
/>Installation
Usage
import { DatePicker, DateRangePicker } from "@/components/ui/date-picker"const [date, setDate] = React.useState<Date>()
<DatePicker value={date} onChange={setDate} />Examples
Range with presets
Presets on the side, two months, and the dashboard numbers roll as the range changes.
Visitors
Signups
In a form
Works with Field: invalid state, error message, weekdays only.
API Reference
DatePicker
| Prop | Type | Default |
|---|---|---|
valueControlled value. | Date | — |
defaultValueInitial value when uncontrolled. | Date | — |
onChangeCalled on select and on clear. | (date: Date | undefined) => void | — |
placeholderShown when empty. | string | "Pick a date" |
formatOptionsHow the value is displayed. | Intl.DateTimeFormatOptions | { dateStyle: "medium" } |
localeUsed for the label and the calendar. | string | "en-US" |
minDate / maxDateBounds passed to the calendar. | Date | — |
disabledDatesDisable specific days. | (date: Date) => boolean | — |
clearableShows an × to reset the value. | boolean | true |
alignPopover alignment. | "start" | "center" | "end" | "start" |
DateRangePicker
Same props as DatePicker, with a DateRange value.
| Prop | Type | Default |
|---|---|---|
presetsShortcuts on the side. Pass `[]` to hide them. | { label: string; range: () => DateRange }[] | — |
numberOfMonthsMonths shown in the popover. | 1 | 2 | 2 |
Notes
- The popover closes on its own once a date — or both ends of a range — are picked, after a short beat so you see the selection land.