Date picker
Swipe the months like pages, with your finger or two fingers on a trackpad. Drag across days to pick a range, or tap both ends; presets sit beside it.
npx shadcn@latest add @captain/date-pickerAgent spend
$158.37over 14 days
Date picker is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { DatePicker } from "@/components/ui/date-picker"
<DatePicker aria-label="Report dates" onValueChange={(r) => load(r.from, r.to)} />Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| value | { from: Date; to: Date } | null | Controlled range. | |
| defaultValue | { from: Date; to: Date } | null | null | Initial range when uncontrolled. |
| onValueChange | (range: DateRange) => void | Called when both ends are picked, or a preset is chosen. | |
| presets | { label: string; range: (today: Date) => DateRange }[] | false | Today, Last 7 days, Last 30 days, This month, Last month | Quick ranges beside the calendar. |
| today | Date | new Date() | Pin today, for tests and screenshots. |
| placeholder | string | "Pick dates" | Trigger text with no range. |
| Calendar | component | The inline calendar on its own, with mode="single" or "range", month, onMonthChange and weekStartsOn. |
Keyboard
- ← → ↑ ↓
- Move by a day or a week
- Home / End
- Start / end of the week
- Page Up / Down
- Previous / next month
- Shift + Page Up / Down
- Previous / next year
- Enter / Space
- Pick an end of the range
- Escape
- Drop a half-picked range, then close
Accessibility
- The trigger has aria-haspopup=dialog and aria-expanded; focus moves to the selected day on open and back to the trigger on Escape.
- Each day is a button named with its full date, aria-pressed when in the range and aria-current on today.
- Roving tabindex across the grid; moving past the edge of a month slides to the next.
- On touch a sideways swipe turns the month and press-and-hold starts a range drag, so the two never fight.