<!-- generated by scripts/gen-docs.mjs from docs/system/calendar.md. Edit the source and rerun. -->
# Calendar

## Description
Shows a month of days, or two side by side, to pick one day, a start and an end, or several days, with today marked and the days you cannot pick held back.

`import { Calendar, daysBetween, formatDate, formatDateRange, formatDays, parseDate, weekStartFor, type DateRange } from "@/components/cobalt/ui/calendar"`, source `registry/cobalt/ui/calendar.tsx`, status `ready-with-gaps`.
Foundation: `hand-rolled on a native table`. Traps checked: `trap/table-divs`, `trap/current-unmarked`, `trap/color-only-status`, `trap/focus-ring-shape`, `trap/hover-beats-focus`, `trap/disabled-still-hovers`, `trap/control-height`, `trap/numbers-shift`, `trap/weight-shift`, `trap/loading-layout-shift`, `trap/button-icon-name`, `trap/touch-hover-flash`.

Where each trap is answered: `trap/table-divs`, each month is a `<table role="grid">` with `<th scope="col">` weekdays; `trap/current-unmarked` and `trap/color-only-status` in States, today carries `aria-current="date"` and a 2px line under its number, a picked day `aria-selected` and the accent fill, a booked day `aria-disabled` and a line through it, a day past `min` or `max` `aria-disabled` and half opacity; `trap/focus-ring-shape`, the shared outline follows each day's corners, square where a run of days joins, and sits 2px out; `trap/hover-beats-focus`, hover is a fill and focus an outline, so both show; `trap/disabled-still-hovers`, a disabled day has no hover fill; `trap/control-height`, a day is 36px, the control height, and 44px tall when `stretch` fills a phone's sheet; `trap/numbers-shift`, days use tabular figures; `trap/weight-shift`, today and the picked day keep the regular weight; `trap/loading-layout-shift` in `rule/calendar-six-weeks`, every month draws six weeks and leaves the days of the months beside it as empty cells; `trap/button-icon-name`, the month and year buttons are named by `labels`; `trap/touch-hover-flash`, the hover fill is guarded by `(hover: hover)` through Tailwind's `hover:`, and a touch picks on lift with no fill before it.

### Foundation
Not applicable: hand-rolled. No Base UI part draws a calendar; this follows the grid the source apps built by hand (`docs/research/2026-10-17-coverage.md`, row 5) and the ARIA date grid pattern.

| Given by the foundation | Added by the team |
|---|---|
| A native `<table>` with `role="grid"`, `<th scope="col" abbr>` headers, and one native `<button>` per day | Six weeks of 36px days from the week holding the 1st, with the control's corner (`--r-lg`, round when controls are pills), the days of a week touching and the weeks 4px apart; the days of the months beside it not drawn, their cells empty and a day tall; one month or two side by side (`months={2}`); month and weekday names, digits and the first day of the week from `Intl` in `locale` (`weekStartFor` reads `Intl.Locale` week data, with a region list where an engine has none); one day in the tab order across both months and the arrow, Home, End and Page keys, focus moved with `preventScroll` so a popup never scrolls the page; `mode="single"`, `"range"` or `"multiple"`; for a range, the two ends in the accent fill and the band between them in the accent's soft tint, a preview of the band and an accent ring on the end a press would pick while the end is open, drawn in the frame the pointer reaches the day, `minDays`, and an end that never runs over a booked night, which stays the check-out once picked; for several days, `maxCount`, and days picked side by side in a week joined into one shape, square where they meet; `min`, `max` and `isDateDisabled`, dimmed and struck through; the month title opens the months of the year and the year a run of twelve years, in the box the days filled; today in `--primary-ink` with a 2px line 10px under the middle of the day; the picked day in the accent fill (D46), changed in the frame of the press with no fade and no press tint, picked as a mouse button goes down and as a touch lifts; days as "YYYY-MM-DD" strings in UTC, so no day slides across a time zone; `parseDate` for typed days in the locale's order; `daysBetween` for a stay's nights; `formatDateRange` and `formatDays` to write a range or several days in the locale's words, with what two ends share written once and the days side by side as one range; previous and next buttons from `Button`, which hang into a sheet's padding when `stretch` so the title and the arrows line up with the sheet's title and close button |

## Examples
One month with today marked and a day picked, the week starting where your locale starts it.

Real uses, 0 call sites (`rg -n "<Calendar\b" app registry --glob '!registry/cobalt/ui/*'`): `DatePicker` renders it inside the ui folder, which this count leaves out.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/calendar/default.tsx` | default | One month with today marked and a day picked, the week starting where your locale starts it |
| `docs/system/examples/calendar/mode-single.tsx` | mode=single | One day, with the pick in the accent and the line under today |
| `docs/system/examples/calendar/mode-range.tsx` | mode=range | The first press sets check-in and the second check-out, and until then the band and the count follow the pointer |
| `docs/system/examples/calendar/mode-multiple.tsx` | mode=multiple | Days picked side by side join into one shape, and once five are picked the other days are held back |
| `docs/system/examples/calendar/locale-de.tsx` | locale=de-DE | In German, month and weekday names come from Intl and the week starts on Monday |
| Not applicable: today is marked in every example | state:today | `--primary-ink` and the 2px line, `aria-current="date"` |
| Not applicable: the picked day in default.tsx | state:selected | The accent fill, `aria-selected` |
| Not applicable: Nov 10 to 12 in mode-multiple.tsx | state:joined | One shape, square where the days meet |
| Not applicable: the nights between in mode-range.tsx | state:in-range | The accent's soft band, `aria-selected` on each day |
| Not applicable: point past check-in in state-disabled.tsx | state:preview | The band drawn to the pointer and an accent ring on that day |
| Not applicable: the cells before the 1st and after the last day in every example | state:outside | Empty cells, a day tall |
| Not applicable: reached with Tab on any example | state:focus-visible | The shared outline round the day |
| `docs/system/examples/calendar/state-disabled.tsx` | state:disabled | Days before today are dimmed, booked nights are struck through, and a stay can end the morning a booked night begins but never runs over it |
| Not applicable: press the month title on any example | state:months | The months of the year in the grid's box |
| `docs/system/examples/calendar/in-card.tsx` | composition:Card | Pick the nights in a listing's card, and the price follows |

Example: One month with today marked and a day picked, the week starting where your locale starts it (`docs/system/examples/calendar/default.tsx`)

```tsx
import { Calendar } from "@/components/cobalt/ui/calendar";

export default function Example() {
  return <Calendar defaultValue="2026-11-12" today="2026-11-03" />;
}
```

Example: Pick the nights in a listing's card, and the price follows (`docs/system/examples/calendar/in-card.tsx`)

```tsx
import { useState } from "react";

import { Calendar, daysBetween, formatDateRange, type DateRange } from "@/components/cobalt/ui/calendar";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { counted, money } from "@/lib/cobalt/format";

const RATE = 145;

export default function Example() {
  const [stay, setStay] = useState<DateRange>({ start: null, end: null });
  const nights = stay.start !== null && stay.end !== null ? daysBetween(stay.start, stay.end) : 0;
  return (
    // As wide as the calendar: the description wraps to it instead of widening the card.
    <Card className="w-min">
      <CardHeader>
        <CardTitle>Harbour loft</CardTitle>
        {/* Two lines whatever is picked, so the calendar under them never moves. */}
        <CardDescription>
          <span className="block">
            {nights > 0
              ? `${counted(nights, { one: "night", other: "nights" })}, ${money(nights * RATE)} before taxes`
              : `${money(RATE)} a night`}
          </span>
          <span className="block">
            {stay.start === null
              ? "Choose check-in, then check-out"
              : stay.end === null
                ? "Choose check-out"
                : formatDateRange(stay.start, stay.end, "en-US")}
          </span>
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Calendar mode="range" value={stay} onValueChange={setStay} minDays={1} today="2026-11-03" min="2026-11-03" />
      </CardContent>
    </Card>
  );
}
```

## Variants

### mode
- `single`: one day, such as a viewing or a report date. Used at 0 call sites; 3 examples (`docs/system/examples/calendar/default.tsx:5`, `docs/system/examples/calendar/mode-single.tsx:10`, `docs/system/examples/calendar/locale-de.tsx:6`).
- `range`: a start and an end, such as a stay. Used at 0 call sites; 3 examples (`docs/system/examples/calendar/mode-range.tsx:16-17`, `docs/system/examples/calendar/state-disabled.tsx:9-10`, `docs/system/examples/calendar/in-card.tsx:35`).
- `multiple`: separate days, such as study days in a reading room. Used at 0 call sites; 1 example (`docs/system/examples/calendar/mode-multiple.tsx:13-14`).

Example: One day, with the pick in the accent and the line under today (`docs/system/examples/calendar/mode-single.tsx`)

```tsx
import { useState } from "react";

import { Calendar, formatDate } from "@/components/cobalt/ui/calendar";

export default function Example() {
  const [day, setDay] = useState<string | null>("2026-11-20");
  return (
    <div className="flex flex-col gap-3">
      <Calendar mode="single" value={day} onValueChange={setDay} today="2026-11-03" />
      <p className="text-sm text-muted-foreground">
        {day === null ? "No viewing booked." : `Viewing on ${formatDate(day, "en-US", { dateStyle: "long" })}.`}
      </p>
    </div>
  );
}
```

Example: The first press sets check-in and the second check-out, and until then the band and the count follow the pointer (`docs/system/examples/calendar/mode-range.tsx`)

```tsx
import { useState } from "react";

import { Calendar, daysBetween, formatDateRange, type DateRange } from "@/components/cobalt/ui/calendar";
import { counted } from "@/lib/cobalt/format";

const nights = (n: number) => counted(n, { one: "night", other: "nights" });

export default function Example() {
  const [stay, setStay] = useState<DateRange>({ start: "2026-11-12", end: "2026-11-16" });
  // The end a press would pick while check-out is open, so the count answers before the press.
  const [preview, setPreview] = useState<string | null>(null);
  const end = stay.end ?? preview;
  return (
    <div className="flex flex-col gap-3">
      <Calendar
        mode="range"
        value={stay}
        onValueChange={setStay}
        onPreviewChange={setPreview}
        minDays={1}
        today="2026-11-03"
        min="2026-11-03"
      />
      <p className="text-sm text-muted-foreground" aria-live="polite">
        {stay.start === null
          ? "Choose check-in"
          : end === null
            ? "Choose check-out"
            : `${formatDateRange(stay.start, end, "en-US")}, ${nights(daysBetween(stay.start, end))}`}
      </p>
    </div>
  );
}
```

Example: Days picked side by side join into one shape, and once five are picked the other days are held back (`docs/system/examples/calendar/mode-multiple.tsx`)

```tsx
import { useState } from "react";

import { Calendar, formatDays } from "@/components/cobalt/ui/calendar";

const MOST = 5;

export default function Example() {
  const [days, setDays] = useState<string[]>(["2026-11-10", "2026-11-11", "2026-11-12", "2026-11-18"]);
  return (
    <div className="flex w-min flex-col gap-3">
      <Calendar
        mode="multiple"
        value={days}
        onValueChange={setDays}
        maxCount={MOST}
        today="2026-11-03"
        min="2026-11-03"
      />
      {/* Two lines kept, so five separate days never push down what is under the calendar. */}
      <p className="min-h-10 text-sm text-muted-foreground" aria-live="polite">
        {days.length === 0 ? (
          "Choose up to five days in the reading room"
        ) : (
          <>
            {formatDays(days, "en-US")},{" "}
            <span className="whitespace-nowrap">
              {days.length} of {MOST} days
            </span>
          </>
        )}
      </p>
    </div>
  );
}
```

Example: In German, month and weekday names come from Intl and the week starts on Monday (`docs/system/examples/calendar/locale-de.tsx`)

```tsx
import { Calendar } from "@/components/cobalt/ui/calendar";

export default function Example() {
  return (
    <Calendar
      locale="de-DE"
      defaultValue="2026-11-12"
      today="2026-11-03"
      labels={{ previousMonth: "Vorheriger Monat", nextMonth: "Nächster Monat" }}
    />
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| rest | a day in the month | press it, arrow to it | its number | test |
| today | the day is `today` | the same as rest | a 2px line under the number in `--primary-ink`, `aria-current="date"` | test |
| selected | the day is the value, a range's start or end, or one of several picked days | pick another, or press again to take it away in `multiple` | the accent fill, `--primary`, with `--primary-foreground` text, as a checked box (D46); `aria-selected="true"` | test |
| joined | several days picked side by side in one week, in `multiple` | press one to take it away, and the run splits in the same frame | one shape: the run's outer corners keep the day's corner and its inner corners are square, `data-joins-before` and `data-joins-after`; a run that wraps to the next week is two shapes, and a day picked under another stays its own, 4px apart | test |
| in-range | a day between a range's start and end | pick it to start again | the accent's soft tint, `--primary-soft`, behind the days, rounded at the ends of the range, of each week and of each month; `aria-selected="true"` | test |
| preview | a range has a start and no end, and the pointer or the arrows rest on a later day it can end on | press to set the end | the band drawn to that day and an inset 1px `--primary-ink` ring on it, in the frame the pointer reaches it; no `aria-selected` until it is picked | by hand |
| not an end | a range waits for its end, and the day is closer to the start than `minDays`, or past the first day taken out after the start, or past the morning the first taken night begins | press it to start the range again from it | half opacity, no line, `data-not-an-end` | test |
| check-out morning | a range waits for its end, and the day begins the first taken night after the start (`isNightDisabled`) | press it to end the stay that morning | its number with no line, as any day it can end on, and the end's fill once picked, though it is struck through while no stay is open | test |
| outside | a day of the month before or after, in the first or last week of the grid | nothing: it is not drawn; the arrows past the month's edge move to it and the calendar to its month | an empty cell a day tall, with no number and no button, so it never reads as a day held back | test |
| hover | pointer over a day, under `(hover: hover)` | press | `--muted` fill, the soft tint again inside the band; a picked day keeps its fill; no fade, so a run or a band never shows grey for a frame | by hand |
| focus-visible | Tab, or any arrow, Home, End or Page key | the keys | the shared 2px outline round the 36px day | screenshot |
| disabled | before `min`, after `max`, `isDateDisabled`, or past `maxCount` | arrow past it; a press does nothing | half opacity, `aria-disabled="true"`, the not-allowed cursor; a booked day (`isDateDisabled`) also carries a line through it | test |
| months | the month title is pressed | pick a month, page a year, press the year for a run of years, Escape back | the months of the year (or twelve years) in the box the days filled, the shown one in the ink fill, neutral as a view you switch to is (D46), `aria-pressed`, this month with today's line | by hand |

Example: Days before today are dimmed, booked nights are struck through, and a stay can end the morning a booked night begins but never runs over it (`docs/system/examples/calendar/state-disabled.tsx`)

```tsx
import { Calendar } from "@/components/cobalt/ui/calendar";

const booked = new Set(["2026-11-06", "2026-11-07", "2026-11-08", "2026-11-19", "2026-11-20"]);

export default function Example() {
  return (
    <div className="flex w-min flex-col gap-3">
      <Calendar
        mode="range"
        minDays={1}
        today="2026-11-03"
        min="2026-11-03"
        max="2027-05-03"
        defaultValue={{ start: "2026-11-12", end: null }}
        isNightDisabled={(night) => booked.has(night)}
      />
      <p className="text-sm text-muted-foreground">
        Struck-through nights are booked. With check-in on Nov 12, check-out can be Nov 13 to Nov 19, the morning the next booking begins.
      </p>
    </div>
  );
}
```

### State precedence
- Selected and today: both show. The accent fill takes `--primary-foreground` text and the line stays, in that colour.
- Selected and hover: selected wins. The accent fill does not change under the pointer.
- Joined and focus-visible: both show. The outline follows the joined day's square inner corners.
- In-range and hover: both show. The day takes the soft tint a second time over the band.
- Preview and hover: both show. The ring sits on the hover fill.
- Disabled and hover: disabled wins. No fill, the not-allowed cursor.
- Disabled and in-range: both show. The band runs behind the struck-through day.
- Disabled and focus-visible: both show. A disabled day can take focus while you arrow past it, so the outline shows where you are.
- Not an end and preview: not an end wins. The band does not reach it, and a press starts the range from it.
- Outside and selected: Not applicable: a day of another month is not drawn, so a picked day shows only in its own month's grid.
- Preview and in-range: Not applicable: the preview shows only while a range has no end, and in-range only once it has one.
- Months and any day state: months wins. The day grids are hidden in place, so the box keeps its size.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| a press on a day | input | none: the fill and its text change in the frame of the press, as a mouse button goes down, a touch lifts, or Enter or Space; no fade and no press tint, so a run reshapes and a band reaches the pointer in one frame | background-color, color, border-radius | the same |

Moving between months, and between the days and the months of the year, has no motion: the grid keeps its six weeks and swaps its numbers, so nothing slides under the pointer.

## Props

<!-- Props generated from registry/cobalt/ui/calendar.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `autoFocus?` | `boolean` |  | Moves focus to the active day when the calendar mounts, as the date picker does when it opens. |
| `className?` | `string` |  |  |
| `defaultMonth?` | `string` |  | The month shown first. |
| `defaultValue?` | `string \| DateRange \| string[]` |  |  |
| `isDateDisabled?` | `(day: string) => boolean` |  | Days that cannot be picked inside min and max, such as nights already booked. |
| `isNightDisabled?` | `(night: string) => boolean` |  | For a stay: the nights already taken, each named by the day it begins. |
| `labels?` | `Partial<CalendarLabels>` |  |  |
| `locale?` | `string` |  | A BCP 47 tag for the month and weekday names, the digits and the first day of the week. |
| `max?` | `string` |  | The last day that can be picked. |
| `maxCount?` | `number` |  | The most days that can be picked; past it, the other days are held back until one is taken away. |
| `min?` | `string` |  | The first day that can be picked. |
| `minDays?` | `number` |  | The fewest days from start to end: 1 for a stay of at least one night. |
| `mode?` | `"single" \| "range" \| "multiple"` |  | One day. |
| `month?` | `string` |  | The first month shown, any day in it. |
| `months?` | `1 \| 2` |  | How many months show side by side: 2 for a stay or a report period on a wide screen. |
| `onMonthChange?` | `(month: string) => void` |  |  |
| `onPreviewChange?` | `(end: string) => void` |  | The end a press would pick while the end is open, under the pointer or the keyboard, or null. |
| `onValueChange?` | `((value: string) => void) \| ((value: DateRange) => void) \| ((value: string[]) => void)` |  |  |
| `stretch?` | `boolean` |  | Draws the grid as wide as its container, each day a seventh of it and 44px tall, as on a phone's sheet. |
| `today?` | `string` |  | The day marked as today. |
| `value?` | `string \| DateRange \| string[]` |  |  |
| `weekStartsOn?` | `number` |  | Overrides the locale's first day of the week, 0 for Sunday to 6 for Saturday. |

Notes only; gen-docs writes the table.
- `mode`: `single` (default), `range` or `multiple`; `value`, `defaultValue` and `onValueChange` take a "YYYY-MM-DD" string for one day, `{ start, end }` for a range, and a sorted array for several days.
- `months`: 1 (default) or 2 side by side. Two months take 520px, 532px in a popup; `DatePicker` shows two for a range from 768px up, where they fit beside the presets, and one below that.
- `minDays` (range): the fewest days from start to end, 1 for a stay of at least one night. `onPreviewChange` (range): the end a press would pick, or null, for a count that answers before the press.
- `isNightDisabled` (range): the nights already taken, each named by the day it begins. No stay holds one, so that day cannot start a stay, but it can end one: check-out is the morning that night begins. `isDateDisabled` takes the whole day out, start and end alike.
- `maxCount` (multiple): the most days that can be picked. Days picked side by side in a week join into one shape.
- `formatDateRange(start, end, locale, options, join)` and `formatDays(days, locale, { year, join })`: a range or several days in the locale's words for a line beside the calendar, "Nov 10 to 12 and Nov 18", with what two ends share written once (`Intl.DateTimeFormat` `formatRangeToParts`) and the list from `Intl.ListFormat`; `join` puts two ends together, "{start} to {end}" by default.
- `locale`: a BCP 47 tag; the device's own by default.
- `weekStartsOn`: 0 for Sunday to 6 for Saturday, over the locale's own.
- `min`, `max` and `isDateDisabled`: the days that cannot be picked. Days past `min` or `max` are dimmed; days `isDateDisabled` returns true for are booked and struck through.
- `today`: the day marked as today; read on the device after the first paint by default, so a server render and the client agree.
- `month`, `defaultMonth` and `onMonthChange`: the first month shown.
- `stretch`: the grid as wide as its container and each day 44px tall, as in the phone's sheet; the title's words and the arrows hang into the container's padding, 10px and 8px, so they line up with a sheet's title and close button.
- `labels`: the month and year buttons' names, and the run of years ("2016 to 2027").
- `autoFocus`: moves focus to the active day as the calendar mounts.

## Usage

### When to use
- Picking a day where seeing the week and month helps, such as a viewing, a booking or a report date.
- Picking a stay or a reporting period, a start and an end, with the days between in view.
- Picking several separate days, such as study days or the days a desk is needed.
- Showing which days cannot be picked, such as nights already booked.

### When not to use
- A form field for a day. Use DatePicker instead, which opens this in a popover, or a sheet on a phone.
- A birth date or a day years away. Use DatePicker instead, with `typed`, so the day is typed rather than paged to.
- A choice among a few named periods, such as "Last 30 days". Use SegmentedControl instead.

### Rules
- `rule/calendar-six-weeks`: When a `Calendar` shows a month, draw six weeks of cells and leave the days of the months before and after it as empty cells a day tall, instead of trimming the empty last week or drawing those days, because a month of five weeks then stands as tall as one of six, paging never moves what is under the grid or the popup's edge, and a day of another month is never mistaken for a day held back. Evidence: measured each calendar at 252x304px and the two-month popup at 532x356px on four months in a row at 1440px, in default and pill corners, with no rect moving in any recorded press, `.design-system/evidence/calendar/accent-runs-2026-10-17.json`; person D37. Check: test calendar.test.tsx "the days of the months beside it are not drawn".
  - Don't: `days.slice(0, weeksInMonth * 7)`
  - Do: `monthGrid(month, weekStart)`
- `rule/calendar-week-from-the-locale`: When a `Calendar` renders, let the first day of the week come from `locale` through `weekStartFor`, and pass `weekStartsOn` only when the product fixes it, instead of hard-coding Sunday, because most of the world starts the week on Monday. Evidence: measured 1 German grid whose first column reads Montag, `.design-system/evidence/calendar/measure.json`; principle platform: `Intl.Locale` week info. Check: test calendar.test.tsx "the week starts where the locale starts it".
  - Don't: `const weekdays = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]`
  - Do: `<Calendar locale="de-DE" />`
- `rule/calendar-days-are-strings`: When a `Calendar` takes or gives a day, pass a "YYYY-MM-DD" string, instead of a `Date` at local midnight, because a `Date` read in another time zone or across a clock change lands on the day before. Evidence: app 7/7 calendars in the examples pass strings (`docs/system/examples/calendar/default.tsx:5`, `docs/system/examples/calendar/mode-range.tsx:22-23`); principle platform: a JavaScript `Date` is an instant, not a calendar day. Check: test calendar.test.tsx "adding days and months keeps to the calendar".
  - Don't: `<Calendar value={new Date(2026, 10, 3)} />`
  - Do: `<Calendar value="2026-11-03" />`
- `rule/calendar-disabled-says-why`: When days are booked, say why in words near the calendar, such as "Struck-through nights are booked", unless the reason is the past, because a line through a number tells you that you cannot pick it but not why. Evidence: principle heuristic: help users recognise, diagnose, and recover; single use docs/system/examples/calendar/state-disabled.tsx:19. Check: review.
  - Don't: `<Calendar isNightDisabled={isBooked} />` alone
  - Do: `<Calendar isNightDisabled={isBooked} />` with `<p>Struck-through nights are booked.</p>`
- `rule/calendar-stay-has-a-night`: When a range is a stay, pass `minDays={1}`, instead of the default 0, because a stay of no nights is a check-in and a check-out on the same day, which no hotel sells, and with `minDays={1}` a second press on check-in keeps waiting for check-out. Evidence: principle heuristic: error prevention; app 3/3 stays in the examples pass it (`docs/system/examples/calendar/mode-range.tsx:21`, `docs/system/examples/calendar/state-disabled.tsx:11`, `docs/system/examples/calendar/in-card.tsx:35`). Check: test calendar.test.tsx "while a range waits for its end".
  - Don't: `<Calendar mode="range" value={stay} onValueChange={setStay} />` for check-in and check-out
  - Do: `<Calendar mode="range" minDays={1} value={stay} onValueChange={setStay} />`
- `rule/calendar-booked-nights`: When the days a stay cannot use are nights already booked, pass them as `isNightDisabled`, instead of `isDateDisabled`, because a booked night blocks the stay over it, not the morning before it: a guest can check out the morning another booking checks in, and `isDateDisabled` would take that check-out away. Evidence: principle heuristic: match between system and the real world; app 2/2 stays with booked nights in the examples pass it (`docs/system/examples/calendar/state-disabled.tsx:16`, `docs/system/examples/date-picker/mode-range.tsx:32`). Check: test calendar.test.tsx "a taken night cannot start a stay, but its morning can end one".
  - Don't: `<Calendar mode="range" minDays={1} isDateDisabled={(day) => bookedNights.has(day)} />`
  - Do: `<Calendar mode="range" minDays={1} isNightDisabled={(night) => bookedNights.has(night)} />`

### Content
- `rule/calendar-days-in-words`: When a line beside a calendar names the days picked, write them with `formatDays`, or a range with `formatDateRange`, in the reader's locale, instead of a count, a colon and each day listed by hand, because days side by side then read as one range, "Nov 10 to 12 and Nov 18", what two ends share is written once, and the copy rules ban a colon-led caption. Evidence: single use docs/system/examples/calendar/mode-multiple.tsx:26; principle platform: `Intl.DateTimeFormat` `formatRangeToParts` and `Intl.ListFormat`. Check: test calendar.test.tsx "several days are a list, the days side by side written as one range".
  - Don't: `` `${days.length} of 5 days: ${days.map((d) => formatDate(d)).join(", ")}` ``
  - Do: `` `${formatDays(days, locale)}, ${days.length} of 5 days` ``
- `rule/calendar-names-from-intl`: When a `Calendar` shows month or weekday names, take them from `locale` through `Intl`, and translate only the month and year buttons and the run of years through `labels`, instead of writing names by hand, because `Intl` already holds every locale's names, digits and order. Evidence: single use docs/system/examples/calendar/locale-de.tsx:7-10; principle platform: `Intl.DateTimeFormat`. Check: review.
  - Don't: `<Calendar labels={{ previousMonth: "Vorheriger Monat" }} />` with "November" still in English
  - Do: `<Calendar locale="de-DE" labels={{ previousMonth: "Vorheriger Monat", nextMonth: "Nächster Monat" }} />`

### Anti-slop
- `rule/calendar-pick-takes-the-accent`: When a day is picked, leave the accent fill the calendar draws instead of an ink or grey fill through `className`, because a picked day is a value picked in a field, which takes the reader's accent as a checked box and a slider's range do, and today's mark is already in the accent, so an ink pick disagrees with it under every accent but ink. Evidence: person D46; measured the picked day's text at 4.75:1 or more and its fill at 3.26:1 or more against the page and the popover, in 6 presets and 9 custom accents, light and dark, `.design-system/evidence/calendar/accent-runs-2026-10-17.json`. Check: lint rule/component-override (scripts/check-system.mjs).
  - Don't: `<Calendar className="[&_[data-selected]]:bg-foreground" />`
  - Do: `<Calendar />`
- `rule/calendar-no-month-animation`: When the month changes, swap the numbers in place instead of wrapping the grid in `Crossfade` or sliding it, because paging is something you do 10 times in a row and a slide waits on every press. Evidence: person D14; principle heuristic: efficiency of use, a frequent action answers at once. Check: review.
  - Don't: `<Crossfade id={month}><Calendar /></Crossfade>`
  - Do: `<Calendar />`

### Limits
- `rule/calendar-range-span`: When a range can run past 2 months, offer typed dates or presets beside the calendar instead of paging alone, because two months show 61 days at most and a 90-day range still needs a page of Page Down while the start is out of sight. Evidence: measured two grids of 252x248px side by side, 61 days at most, `.design-system/evidence/calendar/record-2026-10-17.json`. Check: review.
  - Don't: `<Calendar mode="range" months={2} />` alone for a quarterly report
  - Do: `<DatePicker mode="range" presets={datePresets(today)} typed />`

## Accessibility
Rests on a native `<table role="grid">` per month, labelled by its month title, with a native `<button>` per day. One day is in the tab order across both months.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the calendar | focuses the month title, then the previous and next buttons, then the active day | the picked day, today or the 1st | by hand |
| ArrowRight or ArrowLeft | a day | moves one day, flipped in right-to-left text; the months follow when it leaves them | that day | test |
| ArrowDown or ArrowUp | a day | moves one week | that day | by hand |
| Home or End | a day | moves to the first or last day of its week, in the locale's order, stopping at the month's first or last day, since the days beside it are not drawn | that day | by hand |
| PageDown or PageUp | a day | moves one month, to the same day number or the month's last | that day | by hand |
| Shift+PageDown or Shift+PageUp | a day | moves one year | that day | by hand |
| Enter or Space | a day | picks it; in a range, the first sets the start and the second the end; in several days, adds it or takes it away | the day | by hand |
| a mouse press, a touch | a day | picks it as the mouse button goes down (D43), or as the touch lifts, so a scroll that starts on a day never picks it | the day, with no ring | by hand |
| Enter or Space | the month title | opens the months of the year | the shown month | by hand |
| Arrow keys, Home, End | a month or year | moves among the twelve | that one | by hand |
| Enter or Space | a month | shows that month's days | the active day | by hand |
| Escape | a month or year | back to the days; the popup the calendar sits in stays open | the month title | by hand |

Each day key above was run on the showcase at 1440px and 390px with focus read on every step and the page's scroll unchanged (`.design-system/evidence/calendar/record-2026-10-17.json`), and again on the several-days example with the outline drawn only from the keys (`.design-system/evidence/calendar/accent-runs-2026-10-17.json`).

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| month title | button | `labels.chooseMonth`, "November 2026, choose a month" | the title text is `aria-live="polite"` | the new month as you page | test |
| grid | grid | `aria-labelledby` the month title | `aria-multiselectable` in `range` and `multiple` | "November 2026, grid" | test |
| weekday header | columnheader | `abbr`, the long name | none | the long weekday as you move along a row | test |
| day cell | gridcell | the button inside | `aria-selected` | "selected" on a picked or in-range day | test |
| empty cell | gridcell | none: a day of the month beside it, not drawn | none | "blank" | test |
| day | button | `aria-label`, the full date from `Intl` | `aria-current="date"`, `aria-disabled` | "Thursday, November 12, 2026", "current date", "dimmed" | test |
| previous and next buttons | button | `labels` | `disabled` past `min` or `max` | "Previous month" | test |
| months and years | group of buttons | the year, or the run of years | `aria-pressed` on the one shown, `aria-current="date"` on this month or year, `aria-disabled` outside `min` and `max` | "Mar, toggle button, not pressed" | by hand |

## Tokens
| Part | State | Token |
|---|---|---|
| day | all | 36px, `max(--r-lg, --r-control)`, `--foreground` |
| day | hover | `--muted`; `--primary-soft` again in the band |
| day | today | `--primary-ink` and its 2px line, 10px under the middle |
| day | selected | `--primary` fill, `--primary-foreground` text |
| day | joined | the day's corner outside the run, square inside it |
| day | in-range | `--primary-soft` band, the day's corner at its ends, at the ends of each week and of the month |
| day | preview end | an inset 1px `--primary-ink` ring |
| day | not an end, disabled | `--muted-foreground` at 50 percent; booked struck through |
| cell | outside | empty, a day tall |
| week | all | 4px from the next, `border-spacing-y-1` |
| weekday | all | `--muted-foreground`, text-xs |
| title | all | text-sm, `font-semibold`, a ghost `Button` |

Measured at 1440px and 390px, light and dark, default and pill corners (`.design-system/evidence/calendar/accent-runs-2026-10-17.json`): each calendar 252x304px, the title 32px, the weekdays' 24px row 8px under it and 4px over the first week, six weeks of 36px days 4px apart; two months 520px wide with a 16px gap; inside the date picker the days sit `--pad-popup`, 6px, from the popup's 16px corner, so a corner day's 10px corner is concentric with it. The title's words start 11px in from the grid's edge and the next arrow's glyph ends 14px in from the other; with `stretch` in the phone's sheet they hang into its padding, the title's words at the sheet title's 24px and the arrow buttons over the close button's box. Each day carries `touch-target`, with today's mark moved to `::before` to free `::after`; with `stretch` on a 390px phone a day measures 49x44px. The picked day's text holds 4.75:1 or more on its fill and the fill 3.26:1 or more on the page and the popover, today 4.9:1 or more, the text in the band 11:1 or more, and the preview ring 3.9:1 on the band under the pointer, in the six presets and nine custom accents, light and dark; today inside a band falls to 4.44:1 with a white or pale custom accent on the page, the custom accent's own derivation.

## Related
- DatePicker: the calendar in a field that opens it, in a popover or a phone's sheet.
- Card: the surface a calendar sits on in a page.
- Input: a typed value with a field's look.
- SegmentedControl: a few named periods.
