Skip to content
synccn

Calendar

Month grid for a single date or a range, with disabled days.

 

Mo
Tu
We
Th
Fr
Sa
Su

Pick a start date

Installation

$ pnpm dlx shadcn@latest add @synccn/calendar

First 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 }.

  • mode
    "single" | "range"

    Default "single"

    Pick one day or a span of days.

  • value
    Date | null | DateRange

    Controlled 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
    Date

    Month shown first.

  • disabled
    (date: Date) => boolean

    Return true to block a day.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

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