Skip to content
GetUrUI

Date picker

New
.md

Date and range pickers on a sunken trigger: a popover holds the calendar, presets like Last 7 days and Apply/Cancel, plus a segmented date field whose digits roll as you step them.

date pickerdate rangepresetsdate fieldformcalendar

Installation

$npx shadcn@latest add @geturui/date-picker
Download source (.zip)

Also installs: Calendar, Field, Popover, Button

Usage

usage.tsx
1import { DateField, DatePicker, DateRangePicker, type DateRange } from "@/components/ui/date-picker";
2
3export function ReportControls() {
4  const [launch, setLaunch] = React.useState<Date | null>(null);
5  const [period, setPeriod] = React.useState<DateRange>({ start: null, end: null });
6  return (
7    <>
8      <DatePicker label="Launch date" value={launch} onValueChange={setLaunch} />
9      <DateRangePicker label="Report period" value={period} onValueChange={setPeriod} />
10      <DateField label="Renewal date" />
11    </>
12  );
13}

Props

PropTypeDefaultDescription
value / defaultValue / onValueChangeDate | null (DatePicker) · DateRange (DateRangePicker)—Committed value; changes only on Apply.
label / hint / error / requiredReactNode / boolean—Wired through Field, including aria-describedby and the error shake.
size"sm" | "md" | "lg""md"Trigger height 32 / 40 / 48.
todayDate—Reference day for the marker, presets and Today button. Omit to read the clock after hydration.
min / max / disabledDates / isDateDisabled / highlightedDates / weekStartsOnsee Calendar—Passed to the calendar.
confirmbooleantrueDatePicker: require Apply. When false, picking a day commits and closes.
presetsDatePreset[] | falsedefaultRangePresetsDateRangePicker: { id, label, range(today) } quick ranges in a side column (a scroll row on phones).
numberOfMonths1 | 2—DateRangePicker: defaults to 2 from 640px up, 1 below.
open / defaultOpen / onOpenChange / alignboolean / start | center | end—Popover state and alignment.
DateFieldcomponent—Segmented mm/dd/yyyy input: value, onValueChange, order (mdy | dmy | ymd), min, max, name, size, label, hint, error, bare.

Accessibility

  • The trigger is a button labelled by the field label plus the current value; the popover is a labelled dialog that returns focus on close and cancels on Escape.
  • DateField segments are spinbuttons with aria-valuetext ("October"); arrows step, digits type and auto-advance, Backspace clears.
  • Presets are toggle buttons with aria-pressed; the selected length is announced politely.
  • The calendar inside follows the APG date grid keyboard pattern.

Related