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-picker
inputsnew
Loading…

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/date-range-picker

Manually

  1. Install the dependencies.

    npm install lucide-react motion
  2. Copy these files into your project. Shared files are skipped if you already have them.

    • components/silicon-ui/date-range-picker/date-range-picker.tsx
    • components/silicon-ui/lib/use-today.ts shared
    • components/silicon-ui/date-range-picker/date-range-picker.module.css
  3. Install the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

Source codetsx
import { DateRangePicker } from "@/components/silicon-ui/date-range-picker/date-range-picker";

API reference

PropTypeDefault
value

Controlled value. Pass `null` for no selection.

DateRange | null—
defaultValue

Uncontrolled starting value.

DateRange | nullnull
onChange

Called with the applied range.

(range: DateRange) => void—
label

Accessible name of the trigger and the dialog. Defaults to "Date range".

string"Date range"
placeholderstring"Select dates"
presetsDateRangePreset[]defaultDateRangePresets
minDateDate—
maxDateDate—
weekStartsOn

0 is Sunday, 1 is Monday. Defaults to 0.

0 | 1

01

0
localestring"en-US"
months

Force one or two months. `auto` picks two when the boundary is wide enough.

"auto" | 1 | 2"auto"
boundary

The element the panel should stay inside. Defaults to the viewport.

() => HTMLElement | null—
classNamestring—

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokens