A date picker calendar with single, multiple, and range selection modes.
A fully styled calendar built on react-day-picker. Supports single date selection, date ranges, multiple selection, dropdown month/year navigation, and locale-aware formatting.
"use client"
import * as React from "react"
import { Calendar } from "@/components/ui/calendar"
export default function CalendarDemo() {
const [date, setDate] = React.useState<Date | undefined>(new Date())
return (
<Calendar
mode="single"
selected={date}
onSelect={setDate}
/>
)
}
import { Calendar } from "@/components/ui/calendar"<Calendar />function Demo() {
const [date, setDate] = React.useState<Date | undefined>()
return (
<Calendar
mode="single"
selected={date}
onSelect={setDate}
/>
)
}function Demo() {
const [range, setRange] = React.useState<DateRange | undefined>()
return (
<Calendar
mode="range"
selected={range}
onSelect={setRange}
numberOfMonths={2}
/>
)
}Use captionLayout="dropdown" to show month and year dropdowns instead of a static label.
<Calendar
mode="single"
captionLayout="dropdown"
fromYear={2000}
toYear={2030}
/>Change the navigation button style with the buttonVariant prop.
<Calendar buttonVariant="outline" />A wrapper around react-day-picker's DayPicker with pre-configured styles and components. Accepts all DayPicker props plus the additional props listed below.
| Prop | Type | Default | Description |
|---|---|---|---|
showOutsideDays | boolean | true | Whether to display days from adjacent months. |
captionLayout | "label" | "dropdown" | "dropdown-months" | "dropdown-years" | "label" | Controls how the month/year caption is rendered. |
buttonVariant | ButtonVariant | "ghost" | The variant applied to the previous/next navigation buttons. |
locale | Locale | — | A date-fns locale object for localized formatting. |
formatters | Formatters | — | Custom formatter functions passed to DayPicker. |
components | CustomComponents | — | Custom component overrides passed to DayPicker. |
className | string | — | |
classNames | ClassNames | — | Class name overrides for individual calendar parts. |