Date range picker
A range picker that grows from its trigger into two months with presets and a stretching range highlight.
npx shadcn@latest add @silicon-ui/date-range-pickerInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/date-range-pickerManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/date-range-picker/date-range-picker.tsx
- components/silicon-ui/date-range-picker/date-range-picker.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/use-today.ts
- components/silicon-ui/lib/fluid-hover.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
valueControlled value. Pass `null` for no selection. | DateRange | null | — |
defaultValueUncontrolled starting value. | DateRange | null | null |
onChangeCalled with the applied range. | (range: DateRange) => void | — |
labelAccessible name of the trigger and the dialog. Defaults to "Date range". | string | "Date range" |
placeholder | string | "Select dates" |
presets | DateRangePreset[] | defaultDateRangePresets |
minDate | Date | — |
maxDate | Date | — |
weekStartsOn0 is Sunday, 1 is Monday. Defaults to 0. | 0 | 1
| 0 |
locale | string | "en-US" |
monthsForce one or two months. `auto` picks two when the boundary is wide enough. | "auto" | 1 | 2 | "auto" |
boundaryThe element the panel should stay inside. Defaults to the viewport. | () => HTMLElement | null | — |
className | string | — |
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens