Date Picker
A popover-based date picker wrapping Calendar and Popover. Supports single, range, and multiple selection modes with smart auto-close behavior. Includes a DateTimePicker variant with a scrollable time slot panel.
Installation
npx shadcn@latest add @glrk-ui/date-pickerIf you haven't set up the prerequisites yet, check out registry setup.
DatePicker
Single (default)
import { DatePicker } from "@/components/ui/date-picker"
const [date, setDate] = React.useState<Date | undefined>()
<DatePicker
selected={date}
onSelect={setDate}
startMonth={new Date(2020, 0)}
endMonth={new Date(2030, 11)}
/>Range
Closes automatically once both from and to are selected:
import { type DateRange } from "@daypicker/react"
const [range, setRange] = React.useState<DateRange | undefined>()
<DatePicker
mode="range"
selected={range}
onSelect={setRange}
startMonth={new Date(2020, 0)}
endMonth={new Date(2030, 11)}
/>Multiple
Stays open — no auto-close when toggling individual dates:
const [dates, setDates] = React.useState<Date[] | undefined>()
<DatePicker
mode="multiple"
selected={dates}
onSelect={setDates}
/>Custom date format
dateFormat is a date-fns format string:
<DatePicker selected={date} onSelect={setDate} dateFormat="MMM dd, yyyy" />Custom trigger
triggerProps forwards to the trigger Button — accepts all Button props except children:
<DatePicker
triggerProps={{ variant: "ghost", className: "w-52 border border-dashed" }}
placeholder="Pick a date..."
selected={date}
onSelect={setDate}
/>Controlled open state
const [open, setOpen] = React.useState(false)
<DatePicker open={open} onOpenChange={setOpen} selected={date} onSelect={setDate} />Popup alignment
<DatePicker align="center" selected={date} onSelect={setDate} />
{/* align: "start" | "center" | "end" — default "start" */}Dropdown navigation bounds
captionLayout="dropdown" is the default. Use startMonth / endMonth to limit the month/year dropdown range:
<DatePicker
startMonth={new Date(2020, 0)}
endMonth={new Date(2030, 11)}
selected={date}
onSelect={setDate}
/>Label caption
<DatePicker captionLayout="label" selected={date} onSelect={setDate} />DateTimePicker
Combines the calendar with a scrollable time slot panel in the same popover. Single mode only. Changing the day preserves the selected time; changing the time slot preserves the selected day.
Basic
import { DateTimePicker } from "@/components/ui/date-picker"
const [date, setDate] = React.useState<Date | undefined>()
<DateTimePicker
selected={date}
onSelect={setDate}
startMonth={new Date(2020, 0)}
endMonth={new Date(2030, 11)}
/>12-hour format
<DateTimePicker
selected={date}
onSelect={setDate}
hourFormat={12}
/>Minute step
Controls the interval between time slots. Defaults to 5:
<DateTimePicker selected={date} onSelect={setDate} minuteStep={15} />
<DateTimePicker selected={date} onSelect={setDate} minuteStep={30} />Allowed values: 1 | 5 | 10 | 15 | 20 | 30.
Custom date format
Defaults to "dd/MM/yyyy HH:mm" (24h) or "dd/MM/yyyy hh:mm a" (12h):
<DateTimePicker selected={date} onSelect={setDate} dateFormat="MMM dd, yyyy HH:mm" />Disable past
Blocks all past dates in the calendar and all past time slots on today:
<DateTimePicker selected={date} onSelect={setDate} disablePast />Date range constraint
<DateTimePicker
selected={date}
onSelect={setDate}
minDate={new Date(2025, 0, 1)}
maxDate={new Date(2025, 11, 31)}
/>Minimum datetime
Disables dates before minTime's calendar day, and disables time slots before minTime on that day. Compose with disablePast — the later constraint wins:
const earliest = addMinutes(new Date(), 30)
<DateTimePicker
selected={date}
onSelect={setDate}
minTime={earliest}
disablePast
/>Now / Clear / Done
The footer always shows three actions:
- Now — snaps selection to the current time (rounded to
minuteStep) - Clear — resets the value to
undefined - Done — closes the popover
Controlled open state
<DateTimePicker open={open} onOpenChange={setOpen} selected={date} onSelect={setDate} />Reference
DatePicker
Prop
Type
DateTimePicker
Prop
Type
Related Components
Autocomplete
A wrapper for Base UI Autocomplete with type-to-filter suggestions, grouped items, async search, inline completion mode, and clear/trigger controls.
Field Wrapper
Opinionated form field wrappers combining Field layout, label, error display, and form controls. Available as library-agnostic, React Hook Form, and TanStack Form variants.