Installation
$ pnpm dlx shadcn@latest add @synccn/date-pickerFirst time in this project? Connect synccn with one command.
Usage
import { DatePicker } from "@/components/ui/date-picker";<DatePicker mode="range" value={range} onChange={setRange} />API reference
Generated from the component's TypeScript types, so it always matches the code.
DatePicker
Field that opens a Calendar. mode "single" -> Date, mode "range" -> { from, to }.
PropTypeDescription
- mode
"single" | "range"Default
"single"One date or a range.
- value
Date | null | DateRangeControlled value.
- onChange
((value: Date | null) => void) | ((value: DateRange) => void)Called with the new Date or { from, to }.
- presets
({ label: string; value: () => Date }[]) | ({ label: string; value: () => DateRange }[])Quick picks shown beside the calendar.
- placeholder
stringDefault
"Pick a date"Shown when empty.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Components
- Calendar for
Calendar
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for CalendarDays, X
Keyboard
- EnterorSpaceOpen the calendar
- TabMove through days and presets
- EscClose
Accessibility
- Days are buttons inside a grid with column headers; the selected day sets aria-selected.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: button
- ARIA attributes: aria-expanded, aria-label
- Closes with Escape
- Closes when you click or tap outside
- Flips to whichever side has room, so it stays on screen
- Shows a visible focus ring for keyboard users
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.Radio GroupPick one option, shown as dots or as selectable cards.