Captain UI

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-picker
Pro

Agent spend

$158.37over 14 days

Usage

import { DatePicker } from "@/components/ui/date-picker"

<DatePicker aria-label="Report dates" onValueChange={(r) => load(r.from, r.to)} />

Props

PropTypeDefaultWhat it does
value{ from: Date; to: Date } | nullControlled range.
defaultValue{ from: Date; to: Date } | nullnullInitial range when uncontrolled.
onValueChange(range: DateRange) => voidCalled when both ends are picked, or a preset is chosen.
presets{ label: string; range: (today: Date) => DateRange }[] | falseToday, Last 7 days, Last 30 days, This month, Last monthQuick ranges beside the calendar.
todayDatenew Date()Pin today, for tests and screenshots.
placeholderstring"Pick dates"Trigger text with no range.
CalendarcomponentThe 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.