Skip to content

Calendar

Status: stableAccessibility reviewedtenet-ui@0.4.0
Import
import { Calendar } from 'tenet-ui';

Source: src/components/Calendar/Calendar.tsx

When to use: an always-visible month grid for picking a day — e.g. inline in a booking flow, or hosted in a popover by DatePicker. For a compact field that opens on demand, reach for DatePicker (which wraps this).

  • Give it an accessible name via aria-label (e.g. “Departure date”).
  • Control it with value + onChange, or leave uncontrolled with defaultValue. onChange hands you a real Date.
  • Constrain selectable days with min / max — out-of-range days are disabled and the month-nav arrows stop at the boundary.
  • Set weekStartsOn={1} for Monday-first locales. Month and weekday names follow locale (defaults to the runtime locale) — don’t hardcode English.
  • It implements the ARIA grid + roving-tabindex keyboard model (arrows, Home/End, PageUp/PageDown, Enter/Space). Don’t rebuild this with a plain table of clickable <div>s.
  • <Calendar aria-label="Departure date" defaultValue={new Date()} min={new Date()} />
  • ✅ controlled: <Calendar value={date} onChange={setDate} weekStartsOn={1} />
  • ❌ A grid of <div onClick> cells — no keyboard, no roles, no roving focus.
  • ❌ Formatting the month/weekday labels yourself in English — pass locale and let Intl do it.
4 stories for Calendar — open in Storybook

The full matrix (all args, controls, accessibility panel) is in Storybook.

PropTypeDefaultDescription
valueDate | nullControlled selected date (null = nothing selected).
defaultValueDate | nullUncontrolled initial selected date.
onChange(date: Date) => voidCalled with the chosen date.
monthDateControlled visible month (any day within the month).
defaultMonthDateselected | todayUncontrolled initial visible month. Defaults to the selected date's month, else today.
onMonthChange(month: Date) => voidCalled when the visible month changes (nav buttons / keyboard paging).
minDateEarliest selectable day (inclusive).
maxDateLatest selectable day (inclusive).
weekStartsOnWeekStart0First day of the week: 0 = Sunday (default), 1 = Monday.
localestringruntime localeBCP-47 locale for month / weekday formatting. Defaults to the runtime locale.
classNamestring
aria-labelstring