A month calendar on a table with role grid. Select one date or a range, switch months with buttons or PageUp and PageDown, move between days with the arrow keys. Dates are YYYY-MM-DD strings, month and weekday names come from Intl. Only a small client island runs.
Preview
December 2026
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
2026-12-15
Installation
Usage
"use client"
import * as React from "react"
import { Calendar } from "@/components/ui/calendar"
export default function Example() {
const [date, setDate] = React.useState<string | null>("2026-12-15")
return <Calendar value={date} onValueChange={setDate} />
}Examples
Date range
Click the start, then the end. A third click starts a new range. Weeks start on Monday here.
December 2026
| Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday |
|---|---|---|---|---|---|---|
2026-12-10 - 2026-12-17
<Calendar
mode="range"
weekStartsOn={1}
value={range}
onValueChange={setRange} // { from?: string; to?: string }
/>Limits and disabled days
minDate and maxDate bound the selectable days, disabledDates removes single days.
December 2026
| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |
|---|---|---|---|---|---|---|
<Calendar
minDate="2026-12-08"
maxDate="2027-01-20"
disabledDates={["2026-12-24", "2026-12-25"]}
name="date" // hidden input for forms
/>Keyboard
Arrow keys move by a day or a week, Home and End go to the week edges, PageUp and PageDown change the month, Shift with them changes the year. Enter or Space selects.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| mode | "single" | "range" | "single" | Select one date or a range |
| value | string | null | { from?: string; to?: string } | - | Selected date or range; makes the calendar controlled |
| defaultValue | string | null | { from?: string; to?: string } | - | Initial selection of an uncontrolled calendar |
| onValueChange | (value) => void | - | Called when the selection changes |
| defaultMonth | string | - | Month shown first, YYYY-MM or YYYY-MM-DD |
| minDate | string | - | Earliest selectable day, YYYY-MM-DD |
| maxDate | string | - | Latest selectable day, YYYY-MM-DD |
| disabledDates | string[] | - | Days that cannot be selected |
| name | string | - | Adds hidden form inputs: name, or name-from and name-to in range mode |
| locale | string | "en-US" | BCP 47 locale for month and weekday names |
| weekStartsOn | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | First day of the week: 0 is Sunday, 1 is Monday |
| labels | Partial<CalendarLabels> | - | Texts for screen readers: previousMonth, nextMonth |