Mo
Tu
We
Th
Fr
Sa
Su
Pick a start date
Installation
$ pnpm dlx shadcn@latest add @synccn/calendarFirst time in this project? Connect synccn with one command.
Usage
import { Calendar } from "@/components/ui/calendar";<Calendar mode="range" value={range} onChange={setRange} />API reference
Generated from the component's TypeScript types, so it always matches the code.
Calendar
mode "single": value is a Date. mode "range": value is { from, to }.
PropTypeDescription
- mode
"single" | "range"Default
"single"Pick one day or a span of days.
- value
Date | null | DateRangeControlled selection: a Date in "single" mode, { from, to } in "range" mode.
- onChange
((value: Date) => void) | ((value: DateRange) => void)Called with the new Date or DateRange.
- defaultMonth
DateMonth shown first.
- disabled
(date: Date) => booleanReturn true to block a day.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ChevronLeft, ChevronRight
Used by
Keyboard
- TabMove through the month buttons and days
- EnterorSpacePick the focused day
Accessibility
- Uses grid, columnheader and gridcell roles. The month heading is a live region, so changes are announced.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: columnheader, grid, gridcell
- ARIA attributes: aria-label, aria-live, aria-selected
- Shows a visible focus ring for keyboard users
- Announces changes to screen readers
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.Radio GroupPick one option, shown as dots or as selectable cards.