Skip to content
All components
Forms

Calendar

Show a month grid where people choose a single date, several dates or a range, with keyboard navigation and unavailable days.

Date selection built on React DayPicker.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add calendar

Then import it from @/components/ui/calendar. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Single date

Pick one date in an inline calendar that starts on today. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { Calendar } from "@/components/ui/calendar"

export function CalendarSingleDate() {
  
  const [date, setDate] = React.useState<Date | undefined>(new Date())
  
  
  

  return (
    <div className="flex flex-col gap-8">
      <Calendar
        mode="single"
        selected={date}
        onSelect={setDate}
        className="rounded-16 border border-soft-200 bg-white-0 p-3"
      />
    </div>
  )
}

Date range

Select a start and end date and summarize the range in the calendar footer. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"
import type { DateRange } from "react-day-picker"

import { Calendar } from "@/components/ui/calendar"

const october = new Date(2026, 9, 1)
const day = (value: number) => new Date(2026, 9, value)
const short = (date: Date) => date.toLocaleDateString("en-US", { month: "short", day: "numeric" })

export function CalendarDateRange() {
  const id = React.useId()
  const [date, setDate] = React.useState<Date | undefined>(new Date())
  const [range, setRange] = React.useState<DateRange | undefined>({ from: day(12), to: day(16) })
  
  

  return (
    <div className="flex flex-col gap-8">
      <div role="group" aria-labelledby={`${id}-trip`} className="flex flex-col gap-2">
        <p id={`${id}-trip`} className="text-label-sm text-strong-950">Trip dates</p>
        <Calendar
          mode="range"
          selected={range}
          onSelect={setRange}
          labels={{ labelNav: () => "Trip dates month navigation" }}
          defaultMonth={october}
          footer={
            <p className="mt-3 text-paragraph-sm text-sub-600">
              {range?.from
                ? range.to
                  ? `${short(range.from)} to ${short(range.to)}`
                  : `From ${short(range.from)}. Choose the last day.`
                : "Choose the first day."}
            </p>
          }
        />
      </div>
    </div>
  )
}

Several dates

Select up to three separate days and report how many are chosen. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { Calendar } from "@/components/ui/calendar"

const october = new Date(2026, 9, 1)
const day = (value: number) => new Date(2026, 9, value)

export function CalendarSeveralDates() {
  const id = React.useId()
  
  
  const [days, setDays] = React.useState<Date[] | undefined>([day(6), day(20)])
  

  return (
    <div className="flex flex-col gap-8">
      <div role="group" aria-labelledby={`${id}-office`} className="flex flex-col gap-2">
        <p id={`${id}-office`} className="text-label-sm text-strong-950">Office days</p>
        <Calendar
          mode="multiple"
          max={3}
          selected={days}
          onSelect={setDays}
          labels={{ labelNav: () => "Office days month navigation" }}
          defaultMonth={october}
          footer={
            <p className="mt-3 text-paragraph-sm text-sub-600">
              {days?.length ?? 0} of 3 days selected.
            </p>
          }
        />
      </div>
    </div>
  )
}

Unavailable dates

Skip weekends and past days with disabled matchers and explain why in the footer. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { Calendar } from "@/components/ui/calendar"

const october = new Date(2026, 9, 1)
const day = (value: number) => new Date(2026, 9, value)

export function CalendarUnavailableDates() {
  const id = React.useId()
  
  
  
  

  return (
    <div className="flex flex-col gap-8">
      <div role="group" aria-labelledby={`${id}-delivery`} className="flex flex-col gap-2">
        <p id={`${id}-delivery`} className="text-label-sm text-strong-950">Delivery day</p>
        <Calendar
          mode="single"
          defaultMonth={october}
          disabled={[{ dayOfWeek: [0, 6] }, { before: day(8) }]}
          labels={{ labelNav: () => "Delivery day month navigation" }}
          footer={
            <p className="mt-3 text-paragraph-sm text-sub-600">
              We deliver on weekdays from October 8.
            </p>
          }
        />
      </div>
    </div>
  )
}

Bounded months

Limit navigation to the months in which a choice is possible. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { Calendar } from "@/components/ui/calendar"

const october = new Date(2026, 9, 1)

export function CalendarBoundedMonths() {
  const id = React.useId()
  const [date, setDate] = React.useState<Date | undefined>(new Date())
  
  
  

  return (
    <div className="flex flex-col gap-8">
      <div role="group" aria-labelledby={`${id}-season`} className="flex flex-col gap-2">
        <p id={`${id}-season`} className="text-label-sm text-strong-950">Event date</p>
        <Calendar
          mode="single"
          defaultMonth={october}
          startMonth={october}
          endMonth={new Date(2026, 11, 1)}
          labels={{ labelNav: () => "Event date month navigation" }}
          footer={
            <p className="mt-3 text-paragraph-sm text-sub-600">
              Events run from October to December 2026.
            </p>
          }
        />
      </div>
    </div>
  )
}

Localized

Show month, weekday and day names in another locale with translated day labels. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { es } from "react-day-picker/locale"

import { Calendar } from "@/components/ui/calendar"

const october = new Date(2026, 9, 1)
const day = (value: number) => new Date(2026, 9, value)

export function CalendarLocalized() {
  const id = React.useId()
  
  
  
  const [localized, setLocalized] = React.useState<Date | undefined>(day(15))

  return (
    <div className="flex flex-col gap-8">
      <div role="group" aria-labelledby={`${id}-es`} className="flex flex-col gap-2">
        <p id={`${id}-es`} lang="es" className="text-label-sm text-strong-950">Fecha de entrega</p>
        <Calendar
          mode="single"
          locale={es}
          todayLabel="Hoy"
          selectedLabel="seleccionado"
          selected={localized}
          onSelect={setLocalized}
          defaultMonth={october}
        />
      </div>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

Calendar

Choose dates using a calendar grid.

Calendar props
PropTypeDefaultDescription
mode"single" | "multiple" | "range" | undefined—Enable the selection of a single day, multiple days, or a range of days.
requiredboolean | undefined—Whether the selection is required.
classNamestring | undefined—Class name to add to the root element.
classNamesPartial<import("react-day-picker").ClassNames> | undefined—Change the class names used by DayPicker. Use this prop when you need to change the default class names — for example, when importing the style via CSS modules or when using a CSS framework.
modifiersClassNamesimport("react-day-picker").ModifiersClassNames | undefined—Change the class name for the day matching the modifiers.
styleReact.CSSProperties | undefined—Style to apply to the root element.
stylesPartial<import("react-day-picker").Styles> | undefined—Change the inline styles of the HTML elements.
modifiersStylesimport("react-day-picker").ModifiersStyles | undefined—Change the class name for the day matching the {@link modifiers}.
idstring | undefined—A unique id to add to the root element.
defaultMonthDate | undefined—The initial month to show in the calendar. Use this prop to let DayPicker control the current month. If you need to set the month programmatically, use {@link month} and {@link onMonthChange}.
monthDate | undefined—The month displayed in the calendar. As opposed to defaultMonth, use this prop with onMonthChange to change the month programmatically.
numberOfMonthsnumber | undefined—The number of displayed months.
startMonthDate | undefined—The earliest month to start the month navigation.
endMonthDate | undefined—The latest month to end the month navigation.
pagedNavigationboolean | undefined—Paginate the month navigation displaying the numberOfMonths at a time.
reverseMonthsboolean | undefined—Render the months in reversed order (when {@link numberOfMonths} is set) to display the most recent month first.
hideNavigationboolean | undefined—Hide the navigation buttons. This prop won't disable the navigation: to disable the navigation, use {@link disableNavigation}.
disableNavigationboolean | undefined—Disable the navigation between months. This prop won't hide the navigation: to hide the navigation, use {@link hideNavigation}.
captionLayout"label" | "dropdown" | "dropdown-months" | "dropdown-years" | undefined—Show dropdowns to navigate between months or years. - label: Displays the month and year as a label. Default value. - dropdown: Displays dropdowns for both month and year navigation. - dropdown-months: Displays a dropdown only for the month navigation. - dropdown-years: Displays a dropdown only for the year navigation. **Note:** By default, showing the dropdown will set the {@link startMonth} to 100 years ago and {@link endMonth} to the end of the current year. You can override this behavior by explicitly setting startMonth and endMonth.
reverseYearsboolean | undefined—Reverse the order of years in the dropdown when using captionLayout="dropdown" or captionLayout="dropdown-years".
navLayout"around" | "after" | undefined—Adjust the positioning of the navigation buttons. - around: Displays the buttons on either side of the caption. - after: Displays the buttons after the caption. This ensures the tab order matches the visual order. If not set, DayPicker preserves its legacy layout, but the tab order may not align with the visual order when using captionLayout="dropdown".
fixedWeeksboolean | undefined—Display always 6 weeks per each month, regardless of the month’s number of weeks. Weeks will be filled with the days from the next month.
hideWeekdaysboolean | undefined—Hide the row displaying the weekday row header.
showOutsideDaysboolean | undefinedtrueShow the outside days (days falling in the next or the previous month). **Note:** when a {@link broadcastCalendar} is set, this prop defaults to true.
showWeekNumberboolean | undefined—Show the week numbers column. Weeks are numbered according to the local week index.
animateboolean | undefined—Animate navigating between months.
broadcastCalendarboolean | undefined—Display the weeks in the month following the broadcast calendar. Setting this prop will ignore {@link weekStartsOn} (always Monday) and {@link showOutsideDays} will default to true.
ISOWeekboolean | undefined—Use ISO week dates instead of the locale setting. Setting this prop will ignore weekStartsOn and firstWeekContainsDate.
timeZonestring | undefined—The time zone (IANA or UTC offset) to use in the calendar (experimental). See [Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the possible values.
noonSafeboolean | undefined—Keep calendar math at noon in the configured {@link timeZone} to avoid historical second-level offsets drifting dates across midnight. This prop sets the time of the dates to noon (12:00).
componentsPartial<import("react-day-picker").CustomComponents> | undefined—Change the components used for rendering the calendar elements.
footerReact.ReactNode—Add a footer to the calendar, acting as a live region. Use this prop to communicate the calendar's status to screen readers. Prefer strings over complex UI elements.
autoFocusboolean | undefined—When a selection mode is set, DayPicker will focus the first selected day (if set) or today's date (if not disabled). Use this prop when you need to focus DayPicker after a user action, for improved accessibility.
disabledimport("react-day-picker").Matcher | import("react-day-picker").Matcher[] | undefined—Apply the disabled modifier to the matching days. Disabled days cannot be selected when in a selection mode is set.
hiddenimport("react-day-picker").Matcher | import("react-day-picker").Matcher[] | undefined—Apply the hidden modifier to the matching days. Will hide them from the calendar.
todayDate | undefined—The today’s date. Default is the current date. This date will get the today modifier to style the day.
modifiersRecord<string, import("react-day-picker").Matcher | import("react-day-picker").Matcher[] | undefined> | undefined—Add modifiers to the matching days.
labelsPartial<import("react-day-picker").Labels> | undefined—Labels creators to override the defaults. Use this prop to customize the aria-label attributes in DayPicker.
formattersPartial<import("react-day-picker").Formatters> | undefined—Formatters used to format dates to strings. Use this prop to override the default functions.
dirstring | undefined—The text direction of the calendar. Use ltr for left-to-right (default) or rtl for right-to-left.
aria-labelstring | undefined—The aria-label attribute to add to the container element.
aria-labelledbystring | undefined—The aria-labelledby attribute to add to the container element.
role"dialog" | "application" | undefined—The role attribute to add to the container element.
noncestring | undefined—A cryptographic nonce ("number used once") which can be used by Content Security Policy for the inline style attributes.
titlestring | undefined—Add a title attribute to the container element.
langstring | undefined—Add the language tag to the container element. When omitted, DayPicker uses the active locale code (locale.code). Set this prop to override the language tag.
localePartial<import("react-day-picker").DayPickerLocale> | undefined—The locale object used to localize dates. Pass a locale from react-day-picker/locale/<code> to localize the calendar.
numeralsimport("react-day-picker").Numerals | undefined—The numeral system to use when formatting dates. - latn: Latin (Western Arabic) - arab: Arabic-Indic - arabext: Eastern Arabic-Indic (Persian) - deva: Devanagari - beng: Bengali - guru: Gurmukhi - gujr: Gujarati - orya: Oriya - tamldec: Tamil - telu: Telugu - knda: Kannada - mlym: Malayalam
weekStartsOn0 | 1 | 4 | 3 | 2 | 5 | 6 | undefined—The index of the first day of the week (0 - Sunday). Overrides the locale's default.
firstWeekContainsDate1 | 4 | undefined—The day of January that is always in the first week of the year.
useAdditionalWeekYearTokensboolean | undefined—Enable DD and DDDD for week year tokens when formatting or parsing dates.
useAdditionalDayOfYearTokensboolean | undefined—Enable YY and YYYY for day of year tokens when formatting or parsing dates.
dateLibPartial<DateLib> | undefined—Replace the default date library with a custom one. Experimental: not guaranteed to be stable (may not respect semver).
todayLabelstring | undefined"Today"Word announced before today's date in day button names. Translate it with the rest of the interface, or replace labels.labelDayButton entirely.
selectedLabelstring | undefined"selected"Word announced after a selected date in day button names.

Accessibility & usage

From registry/ui/calendar.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • An always-visible date choice that is the main content of a panel, such as booking or scheduling views.
  • Selecting a range or several separate days, where seeing the whole month helps.
  • Inside DatePicker's popup (it is already composed there).

When not to use

  • A date in a form field; use DatePicker so the value has a labelled trigger.
  • Dates people know by heart, such as a date of birth; use a text input with a documented format.
  • Times of day or durations.

Anatomy

Calendar
React DayPicker with TDPXL classes. Takes mode (single, multiple, range), selected, onSelect, disabled matchers, locale, startMonth, endMonth, numberOfMonths, footer and the other DayPicker props.
Caption and navigation
Month label (announced politely when it changes) with previous and next month buttons.
Grid
One grid per month; weekday headers and day buttons named with the full date, plus 'Today' and 'selected' words.
Footer
Optional content announced politely; use it to summarize the selection or explain constraints.

Keyboard & interaction

  • Arrow keys move one day or one week; Page Up and Page Down move one month; Shift with Page Up or Page Down moves one year; Home and End go to the start and end of the week.
  • Enter or Space selects the focused day; in range mode the first selection sets the start and the next one the end.
  • Disabled days stay visible and cannot be selected; keyboard focus skips them.
  • Navigation buttons stop at startMonth and endMonth.
  • Today is marked with an outline and announced with todayLabel; selected days are filled and announced with selectedLabel.

Responsive behavior

  • Day buttons are 36 CSS px, above the 24 px minimum; one month needs about 280 CSS px including padding.
  • With numberOfMonths above 1, months stack on narrow screens and sit side by side from the small breakpoint; prefer one month on phones.
  • Days from adjacent months are shown by default and stay readable; turn them off with showOutsideDays={false} if they distract, or use fixedWeeks to keep the height stable between months.
  • Week start, month and weekday names follow the locale.

Content guidelines

  • Label the calendar with a visible title nearby ('Trip dates') and connect it with a named group.
  • Use the footer to confirm the selection in words ('Oct 12 to Oct 16') and to explain unavailable days.
  • Translate todayLabel and selectedLabel with the locale.

Alternatives

  • Date picker — A form field that opens this calendar in a popup.
  • Input — Typed dates that people already know.
  • Native select — Coarse choices such as a month or a year.

Resources