Date picker

Choose a date without losing context.

npx shadcn@latest add @silicon-ui/date-picker
datefield
Loading…

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/date-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-picker/date-picker.tsx
    • components/silicon-ui/date-picker/date-picker.module.css
    • components/silicon-ui/calendar/calendar.tsx shared
    • components/silicon-ui/lib/use-today.ts shared
    • components/silicon-ui/calendar/calendar.module.css shared
  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 { DatePicker } from "@/components/silicon-ui/date-picker/date-picker";

API reference

PropTypeDefault
label*string—
valueDate—
onChange(date: Date | undefined) => void—
descriptionstring—
placeholderstring"Select a date"
minDateDate—
maxDateDate—
disabledDatesCalendarDateMatcher—
localestring"en-US"
formatIntl.DateTimeFormatOptions{ month: "short", day: "numeric", year: "numeric" }
showToday

Adds a Today button to the calendar header.

boolean—

Also accepts the props of ButtonHTMLAttributes<HTMLButtonElement>, except value, onChange.

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokenscalendar