Calendar
A date field for picking single dates, ranges and multiples.
Installation
npx shadcn@latest add @blank/calendarUsage
import { Calendar } from "@/components/ui/calendar"const [date, setDate] = React.useState<Date | undefined>(new Date())
<Calendar mode="single" selected={date} onSelect={setDate} />To open a calendar from a field, put it in a Popover. Date Picker shows how.
Examples
Range
mode="range" with two months side by side. Each week of a range reads as one capsule, so a range that spans weeks still scans as a single selection.
Month and year dropdowns
captionLayout="dropdown" for dates far from today, like a birthday. Bound it with startMonth and endMonth.
API Reference
Calendar
Every react-day-picker DayPicker prop (mode, selected, onSelect, disabled, numberOfMonths and the rest), plus:
| Prop | Type | Default |
|---|---|---|
animate | boolean — slide the weeks and fade the caption on month change | true |
buttonVariant | any Button variant | "ghost" |
showOutsideDays | boolean | true |
captionLayout | "label" | "dropdown" | "dropdown-months" | "dropdown-years" | "label" |
CalendarDayButton
The day cell, exported so a custom components.DayButton can wrap it instead of starting over.