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

## Description
Holds a day, a start and an end, or several days in a form field that opens a calendar to pick them and sends them with the form.

`import { DatePicker, datePresets, type DatePreset } from "@/components/cobalt/ui/date-picker"`, source `registry/cobalt/ui/date-picker.tsx`, status `ready-with-gaps`.
Foundation: `team composition over Popover and Calendar`. Traps checked: `trap/field-label`, `trap/label-unbound`, `trap/field-error-link`, `trap/field-keeps-input`, `trap/select-empty-value`, `trap/control-height`, `trap/focus-ring-shape`, `trap/hover-beats-focus`, `trap/disabled-still-hovers`, `trap/open-trigger-unfocused`, `trap/overlay-focus-return`, `trap/motion-origin`, `trap/touch-autofocus`, `trap/native-control`.

Where each trap is answered: `trap/field-label` and `trap/label-unbound` through `rule/input-has-a-label`, the trigger takes the `FieldLabel` through `FieldControl`; `trap/field-error-link` through `rule/input-error-is-linked`; `trap/field-keeps-input`, the value is held by the host or by the picker and survives a failed submit, and a typed day that cannot be read stays in its field with the reason below the calendar; `trap/select-empty-value` in `rule/date-picker-clear-when-optional`; `trap/control-height` in Tokens, the trigger measures 36px; `trap/focus-ring-shape`, Tab draws the field's edge and ring on the trigger's `--r-control` corner, the same as Input (D40); `trap/hover-beats-focus` and `trap/disabled-still-hovers`, the trigger has no hover look; `trap/open-trigger-unfocused`, focus moves into the calendar and the trigger keeps `aria-expanded="true"`; `trap/overlay-focus-return` in Keyboard, focus goes back to the trigger after a pick, Done or Escape (measured); `trap/motion-origin` in Motion, the popup fades in place 4px below and the phone's sheet slides up from the bottom edge; `trap/touch-autofocus`, opening moves focus to a day button, which raises no keyboard, and the typed fields take focus only when pressed; `trap/native-control` in Anti-slop, no styled `<input type="date">`.

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| `Popover` and `Calendar` from this registry. `Popover` is Base UI `Popover` from 640px up, a trigger with `aria-haspopup="dialog"` and `aria-expanded` and a portaled popup with focus moved in and back, Escape and an outside press to close; below 640px it is the registry's bottom `Sheet` (D8) | A trigger in the field's look: `bg-input/50`, `--r-control`, `min-h-(--control)`, the calendar glyph, the value in the locale's words or the placeholder in the muted ink, as wide as its field whatever it holds, `field-focus` with the shared outline off (`data-focus="custom"`); `mode="single"`, `"range"` or `"multiple"`; two months side by side for a range from 768px up, where they fit beside the presets, one month below that, and one month at full width on a phone (`stretch`), days 44px tall; typed fields as wide as the calendar, never wider; the popup's days `--pad-popup` from its edge, so a day's corner is concentric with the popup's; the calendar opens on the selection's month, or today's, each time; one day closes the popup as it is picked, a range once its end is picked (on a phone the sheet waits for Done), several days at Done; the value in the field written through `formatDateRange` and `formatDays` from Calendar, what a range's two ends share written once ("Nov 12 to 16, 2026") and days side by side as one range ("Nov 10 to 12 and Nov 18, 2026"); a footer that says how far the range reaches as you point ("4 nights" with `count="nights"`, "30 days" with `count="days"`, "Nov 12 to 16, 2026" with neither), how many days are picked, or the day in full, and holds Clear (`clearable`, and always for several days) and Done; `typed` fields to type a day, or a range's two ends, in the locale's own order, read by `parseDate`, with the reason a day was refused in the footer; the value as "YYYY-MM-DD" in hidden inputs named by `name` (one per day for several), or `startName` and `endName`; for a range, optional `presets` (from `datePresets`) as menu rows beside the calendar, or pills above it on a phone, that pick the range in one press, with the field reading the preset's name while the range matches it |

## Examples
A filter field that opens a calendar below it; picking a day closes it, and Clear empties it.

Real uses, 0 call sites (`rg -n "<DatePicker\b" app registry --glob '!registry/cobalt/ui/*'`): none yet; both source apps hand-roll one (`docs/research/2026-10-17-coverage.md`, row 5).

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/date-picker/default.tsx` | default | A filter field that opens a calendar below it; picking a day closes it, and Clear empties it |
| `docs/system/examples/date-picker/mode-single.tsx` | mode=single | One day, shown in the field in the reader's own words |
| `docs/system/examples/date-picker/mode-range.tsx` | mode=range | Check-in and check-out in one field, with the nights counted as you point and check-out allowed on the morning a booked night begins |
| `docs/system/examples/date-picker/mode-multiple.tsx` | mode=multiple | Several study days in one field, each press adding a day or taking it away, until Done closes the calendar |
| `docs/system/examples/date-picker/presets.tsx` | state:preset | Last 30 days, This quarter or Year to date in one press beside the calendar, and the field names the range |
| `docs/system/examples/date-picker/typed.tsx` | typed=true | Type the report date in your own format or pick it, and a date that cannot be read says so below the calendar |
| Not applicable: default.tsx at rest | state:empty | The placeholder in the muted ink |
| Not applicable: mode-single.tsx holds a day | state:filled | The day in the locale's words |
| Not applicable: press any trigger | state:open | The calendar 4px below, focus on a day; a bottom sheet below 640px |
| Not applicable: reached with Tab on any example | state:focus-visible | The field's accent edge and ring |
| `docs/system/examples/date-picker/state-disabled.tsx` | state:disabled | A disabled field keeps its date at half opacity and does not open |
| `docs/system/examples/date-picker/state-invalid.tsx` | state:invalid | The red wash on the field and the error that names the fix |
| `docs/system/examples/date-picker/in-field.tsx` | composition:Field | The label names the field, and the description says what the day changes |

Example: A filter field that opens a calendar below it; picking a day closes it, and Clear empties it (`docs/system/examples/date-picker/default.tsx`)

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

import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  const [day, setDay] = useState<string | null>(null);
  return (
    <Field className="w-full max-w-72">
      <FieldLabel>Filed on or after</FieldLabel>
      <FieldControl
        render={
          <DatePicker
            value={day}
            onValueChange={setDay}
            clearable
            placeholder="Any date"
            name="filedAfter"
            today="2026-11-03"
            max="2026-11-03"
          />
        }
      />
    </Field>
  );
}
```

Example: The label names the field, and the description says what the day changes (`docs/system/examples/date-picker/in-field.tsx`)

```tsx
import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  return (
    <Field className="w-full max-w-60">
      <FieldLabel>Report date</FieldLabel>
      <FieldControl render={<DatePicker defaultValue="2026-09-30" today="2026-11-03" max="2026-11-03" />} />
      <FieldDescription>Holdings are shown as filed on this day.</FieldDescription>
    </Field>
  );
}
```

## Variants

### mode
- `single`: one day. Used at 0 call sites; 6 examples (`docs/system/examples/date-picker/default.tsx:14`, `docs/system/examples/date-picker/mode-single.tsx:13`, `docs/system/examples/date-picker/typed.tsx:14`, `docs/system/examples/date-picker/state-disabled.tsx:9`, `docs/system/examples/date-picker/state-invalid.tsx:9`, `docs/system/examples/date-picker/in-field.tsx:9`).
- `range`: a start and an end in one field, such as a stay or a filing period. Used at 0 call sites; 2 examples (`docs/system/examples/date-picker/mode-range.tsx:21-22`, `docs/system/examples/date-picker/presets.tsx:19-20`).
- `multiple`: several separate days in one field. Used at 0 call sites; 1 example (`docs/system/examples/date-picker/mode-multiple.tsx:14`).

Example: One day, shown in the field in the reader's own words (`docs/system/examples/date-picker/mode-single.tsx`)

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

import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  const [day, setDay] = useState<string | null>("2026-11-20");
  return (
    <Field className="w-full max-w-60">
      <FieldLabel>Viewing day</FieldLabel>
      <FieldControl
        render={<DatePicker mode="single" value={day} onValueChange={setDay} today="2026-11-03" min="2026-11-03" />}
      />
    </Field>
  );
}
```

Example: Check-in and check-out in one field, with the nights counted as you point and check-out allowed on the morning a booked night begins (`docs/system/examples/date-picker/mode-range.tsx`)

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

import { daysBetween, type DateRange } from "@/components/cobalt/ui/calendar";
import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/cobalt/ui/field";
import { counted, money } from "@/lib/cobalt/format";

const RATE = 145;
// The nights already taken, each named by the day it begins.
const booked = new Set(["2026-11-20", "2026-11-21", "2026-11-22"]);

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 (
    <Field className="w-full max-w-72">
      <FieldLabel>Dates of stay</FieldLabel>
      <FieldControl
        render={
          <DatePicker
            mode="range"
            value={stay}
            onValueChange={setStay}
            count="nights"
            minDays={1}
            placeholder="Add dates"
            startName="checkIn"
            endName="checkOut"
            today="2026-11-03"
            min="2026-11-03"
            isNightDisabled={(night) => booked.has(night)}
            labels={{
              dialog: "Dates of stay",
              chooseStart: "Choose check-in",
              chooseEnd: "Choose check-out",
              start: "Check-in",
              end: "Check-out",
            }}
          />
        }
      />
      {/* Two lines whatever is picked, so the price changing moves nothing under the field. */}
      <FieldDescription>
        <span className="block">
          {nights > 0
            ? `${counted(nights, { one: "night", other: "nights" })}, ${money(nights * RATE)} before taxes.`
            : `${money(RATE)} a night.`}
        </span>
        <span className="block">Struck-through nights are booked.</span>
      </FieldDescription>
    </Field>
  );
}
```

Example: Several study days in one field, each press adding a day or taking it away, until Done closes the calendar (`docs/system/examples/date-picker/mode-multiple.tsx`)

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

import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  const [days, setDays] = useState<string[]>(["2026-11-10", "2026-11-12"]);
  return (
    <Field className="w-full max-w-72">
      <FieldLabel>Reading room days</FieldLabel>
      <FieldControl
        render={
          <DatePicker
            mode="multiple"
            value={days}
            onValueChange={setDays}
            maxCount={5}
            name="days"
            placeholder="Choose days"
            today="2026-11-03"
            min="2026-11-03"
          />
        }
      />
      <FieldDescription>Up to five days. A desk is held for you from 9am on each one.</FieldDescription>
    </Field>
  );
}
```

Example: Type the report date in your own format or pick it, and a date that cannot be read says so below the calendar (`docs/system/examples/date-picker/typed.tsx`)

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

import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  const [day, setDay] = useState<string | null>("2026-09-30");
  return (
    <Field className="w-full max-w-72">
      <FieldLabel>Report date</FieldLabel>
      <FieldControl
        render={
          <DatePicker
            value={day}
            onValueChange={setDay}
            typed
            today="2026-11-03"
            min="2011-11-01"
            max="2026-11-03"
          />
        }
      />
      <FieldDescription>Holdings are shown as filed on this day. Type 9/30/2025, Sep 30 2025 or 2025-09-30.</FieldDescription>
    </Field>
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| empty | no value | open the calendar | the placeholder in `--muted-foreground`, `data-placeholder` | test |
| filled | a value | open it, pick another | "Nov 3, 2026"; "Nov 12 to 16, 2026" for a range, what the two ends share written once; "Nov 10 to 12 and Nov 18, 2026" for several days in up to three runs of days side by side, "5 days" past that | test |
| partial range | a start and no end | open it and pick the end | "From Nov 12, 2026" in the field; "Choose the last day", or the count to the pointer, in the footer | test |
| preset | the range equals a preset's | open it and pick another preset or days | the field reads "Last 30 days"; in the open popup the preset's row carries the check and `aria-pressed="true"`, or its pill is on | test |
| open | a press, Enter or Space on the trigger, or a click on its label | arrow through the days, pick, Escape | the calendar 4px below at the field's start edge, flipped above when there is no room, `aria-expanded="true"`, focus on a day; below 640px a bottom sheet titled by `labels.dialog` | by hand |
| typed refused | a typed text that is not a day, a day that cannot be picked, or an end before the start | fix the text, or Escape to put the day back | the red wash on the typed field, `aria-invalid`, and the reason in the footer in `--destructive`, read out politely | by hand |
| focus-visible | Tab to the trigger | open with Enter or Space | the 1px `--primary` edge and 3px ring at 20 percent; a click shows nothing (D40) | screenshot |
| disabled | `disabled`, or from `Field` | nothing | half opacity, the not-allowed cursor; the trigger leaves the tab order | test |
| invalid | `aria-invalid`, or from `Field` when a `FieldError` renders | pick a day | the red wash and the linked error | test |

Example: Last 30 days, This quarter or Year to date in one press beside the calendar, and the field names the range (`docs/system/examples/date-picker/presets.tsx`)

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

import type { DateRange } from "@/components/cobalt/ui/calendar";
import { DatePicker, datePresets } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/cobalt/ui/field";

const today = "2026-11-03";
const presets = datePresets(today);

export default function Example() {
  // Opens on the last 30 days, so the field reads the preset's name rather than two dates.
  const [filed, setFiled] = useState<DateRange>(presets[1]!.range());
  return (
    <Field className="w-full max-w-72">
      <FieldLabel>Filed between</FieldLabel>
      <FieldControl
        render={
          <DatePicker
            mode="range"
            value={filed}
            onValueChange={setFiled}
            presets={presets}
            count="days"
            typed
            today={today}
            max={today}
          />
        }
      />
      <FieldDescription>Holdings reports and offering notices filed in this range.</FieldDescription>
    </Field>
  );
}
```

Example: A disabled field keeps its date at half opacity and does not open (`docs/system/examples/date-picker/state-disabled.tsx`)

```tsx
import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldDescription, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  return (
    <Field className="w-full max-w-60" disabled>
      <FieldLabel>Contract start</FieldLabel>
      <FieldControl render={<DatePicker defaultValue="2026-01-01" />} />
      <FieldDescription>Set when the contract was signed.</FieldDescription>
    </Field>
  );
}
```

Example: The red wash on the field and the error that names the fix (`docs/system/examples/date-picker/state-invalid.tsx`)

```tsx
import { DatePicker } from "@/components/cobalt/ui/date-picker";
import { Field, FieldControl, FieldError, FieldLabel } from "@/components/cobalt/ui/field";

export default function Example() {
  return (
    <Field className="w-full max-w-60">
      <FieldLabel>Check-in</FieldLabel>
      <FieldControl render={<DatePicker placeholder="Choose a date" today="2026-11-03" min="2026-11-03" />} />
      <FieldError>Choose a check-in date to see the price.</FieldError>
    </Field>
  );
}
```

### State precedence
- Disabled and open: disabled wins. The calendar does not open.
- Disabled and invalid: disabled wins. The wash fades with the trigger, and the host drops the error.
- Open and invalid: both show. The wash stays under the calendar.
- Open and focus-visible: open wins. Focus is on a day, and the trigger keeps its fill and `aria-expanded="true"`.
- Partial range and open: both show. The calendar shows the start and previews the band to the pointer.
- Empty and filled: Not applicable: the field holds a value or it does not.
- Preset and partial range: partial range wins. A preset is a whole range, so a start alone matches none and the field reads "From".
- Preset and open: both show. The field keeps the preset's name and its row is checked beside the calendar, which shows the range.
- Typed refused and open: both show. The refused text stays in its field and the footer says why until the text is fixed, put back or a day is picked.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| closed to open, from 640px up | announce | `popup-motion`, `--t-pop` on `--curve`, from `Popover` | opacity | the fade stays; nothing moves |
| open to closed by a pick, Done, Escape or an outside press | announce | `popup-motion` at 70 percent of `--t-pop`, from `Popover`, which keeps the fade when Base UI marks a close instant (D36) | opacity | the same |
| closed to open, below 640px | announce | the Sheet's slide up, `--t-sheet` on `--curve-sheet`, over the scrim; down in `--t-leave` on close | translate | a fade in `--t-fade` |
| Tab ring arriving | input | `duration-press` | box-shadow | the ring appears at once |

## Props

<!-- Props generated from registry/cobalt/ui/date-picker.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `clearable?` | `boolean` |  | Clear in the popup, for an optional field whose empty value means something, such as "Any date". |
| `count?` | `"nights" \| "days"` |  | Counts the range in the footer as you pick: "nights" for a stay (end less start), "days" for a period (both ends counted). |
| `defaultOpen?` | `boolean` |  |  |
| `defaultValue?` | `string \| DateRange \| string[]` |  |  |
| `endName?` | `string` |  |  |
| `isDateDisabled?` | `(day: string) => boolean` |  |  |
| `isNightDisabled?` | `(night: string) => boolean` |  | For a stay, the nights already taken, each named by the day it begins: no stay holds one, and check-out can be its morning. |
| `labels?` | `Partial<DatePickerLabels>` |  |  |
| `locale?` | `string` |  |  |
| `max?` | `string` |  |  |
| `maxCount?` | `number` |  | The most days that can be picked. |
| `min?` | `string` |  |  |
| `minDays?` | `number` |  | The fewest days from start to end: 1 for a stay of at least one night. |
| `mode?` | `"single" \| "range" \| "multiple"` |  | `single` one day; `range` a start and an end in one field; `multiple` several separate days in one field. |
| `months?` | `1 \| 2` |  | Months side by side in the anchored popup: 2 by default for a range, 1 otherwise. |
| `name?` | `string` |  | For one day, or several, the form field that carries each as "YYYY-MM-DD". |
| `onOpenChange?` | `(open: boolean) => void` |  |  |
| `onValueChange?` | `((value: string) => void) \| ((value: DateRange) => void) \| ((value: string[]) => void)` |  |  |
| `open?` | `boolean` |  |  |
| `phone?` | `"popover" \| "sheet"` |  | Below 640px the calendar opens in a bottom sheet; "popover" keeps the anchored popup. |
| `placeholder?` | `string` |  | The trigger's text while nothing is picked: "Any date", "Add dates". |
| `presets?` | `DatePreset[]` |  | Named ranges beside the calendar (above it on a phone); the field reads the name of the one picked. |
| `startName?` | `string` |  | For a range, the form fields that carry its two ends. |
| `today?` | `string` |  |  |
| `typed?` | `boolean` |  | Fields above the calendar to type a day in, for work where people already know the date. |
| `value?` | `string \| DateRange \| string[]` |  |  |
| `weekStartsOn?` | `number` |  |  |

Also accepts every native `<button>` attribute.

Notes only; gen-docs writes the table.
- `mode`: `single` (default), `range` or `multiple`; `value`, `defaultValue` and `onValueChange` take a "YYYY-MM-DD" string or null, `{ start, end }`, or a sorted array.
- `name` for one day or several (one hidden input per day), `startName` and `endName` for a range.
- `placeholder`: the trigger's text with nothing picked.
- `locale`, `weekStartsOn`, `min`, `max`, `isDateDisabled` and `today` pass to `Calendar`.
- `months`: two for a range from 768px up and one otherwise in the anchored popup; a phone always shows one. Passing it fixes the count.
- `count` (range): `nights` counts end less start, for a stay; `days` counts both ends, for a period. `minDays` (range): 1 for a stay of at least one night. `isNightDisabled` (range): the nights already taken, as in Calendar: no stay holds one, check-out can be its morning, and a typed range is checked the same way. `maxCount` (multiple): the most days.
- `typed`: fields above the calendar to type the day, or the two ends, in the locale's order ("11/12/2026", "12.11.2026", "Nov 12", "2026-11-12"). Enter or leaving the field reads it; Escape puts the day back.
- `clearable`: Clear in the footer, which empties the field. Several days always have it.
- `phone`: `sheet` (default) opens a bottom sheet below 640px; `popover` keeps the anchored popup.
- `open`, `defaultOpen` and `onOpenChange`: the popup's state.
- `labels`: the month and year buttons; the popup's name and the sheet's title ("Choose a date", "Choose dates"); the range wording ("{start} to {end}", "From {start}"); the typed fields' names ("Date", "Start", "End"); the footer's words ("Choose the first day", "Choose the last day", "No date chosen", nights, days, picked); the typed reasons; Clear and Done; the presets group ("Ranges").
- `presets`, for `mode="range"`: `{ label, range }` pairs, `range` read at each render so a preset that ends today stays true. `datePresets(today)` gives Last 7 days, Last 30 days, This quarter, Last quarter and Year to date.
- Every other attribute, `id`, `aria-invalid`, `aria-describedby` and `disabled` among them, goes to the trigger, so `FieldControl` wires it.

## Usage

### When to use
- A form or filter field for a day, such as a check-in date or "filed on or after".
- A stay or a reporting period, a start and an end in one field.
- Several separate days in one field, such as the days a desk is booked.

### When not to use
- A calendar that is the page's main content, always in view. Use Calendar instead.
- Only a few named periods and never days of your own, such as a chart's 1M, 3M, 1Y. Use SegmentedControl instead.

### Rules
- Follows `rule/input-has-a-label`.
- Follows `rule/input-error-is-linked`.
- `rule/date-picker-through-field-control`: When a `DatePicker` sits in a `Field`, render it through `FieldControl` instead of giving it an `id` by hand, because `FieldControl` passes the id the label points at, the description and the error, and `aria-invalid`, to the trigger. Evidence: app 9/9 pickers in the examples render through `FieldControl` (`docs/system/examples/date-picker/default.tsx:12-14`, `docs/system/examples/date-picker/in-field.tsx:9`); person D34. Check: review.
  - Don't: `<FieldLabel htmlFor="checkin">Check-in</FieldLabel><DatePicker id="checkin" />`
  - Do: `<FieldLabel>Check-in</FieldLabel><FieldControl render={<DatePicker />} />`
- `rule/date-picker-range-is-one-field`: When the field holds a start and an end, use one `DatePicker` with `mode="range"` instead of two pickers side by side, because one calendar shows both days and the nights between, and two pickers let the end land before the start. Evidence: app 2/2 ranges in the examples are one field (`docs/system/examples/date-picker/mode-range.tsx:21-22`, `docs/system/examples/date-picker/presets.tsx:19-20`); principle heuristic: error prevention. Check: review.
  - Don't: `<DatePicker name="checkIn" /><DatePicker name="checkOut" />`
  - Do: `<DatePicker mode="range" startName="checkIn" endName="checkOut" />`
- `rule/date-picker-clear-when-optional`: When the day is optional, pass `clearable` instead of a button of your own beside the field or no way back, because the calendar has no "no day" to pick, and Clear in the popup sits with the days it empties. Evidence: principle heuristic: user control and freedom; single use docs/system/examples/date-picker/default.tsx:17. Check: review of every optional picker.
  - Don't: `<DatePicker placeholder="Any date" />` beside `<Button variant="ghost" onClick={() => setDay(null)}>Clear date</Button>`
  - Do: `<DatePicker clearable placeholder="Any date" value={day} onValueChange={setDay} />`
- `rule/date-picker-bound-the-days`: When some days cannot be picked, pass `min`, `max` or `isDateDisabled` instead of checking the day after the pick, because the calendar then dims or strikes those days before you press one, and a typed day outside them is refused with its reason. Evidence: app 8/9 pickers in the examples bound their days (`docs/system/examples/date-picker/default.tsx:21`, `docs/system/examples/date-picker/mode-range.tsx:31`); principle heuristic: error prevention. Check: review.
  - Don't: `onValueChange={(d) => d < today && setError("Choose a later day")}`
  - Do: `<DatePicker min={today} />`
- `rule/date-picker-stay-counts-nights`: When the range is a stay, pass `count="nights"` and `minDays={1}`, instead of leaving the count to the page, because the number of nights is what the guest pays for, and the footer then answers it as the pointer moves, before the second press. Evidence: principle heuristic: visibility of system status; single use docs/system/examples/date-picker/mode-range.tsx:25-26; measured "5 nights" in the footer with the pointer on Nov 17 and check-in on Nov 12, `.design-system/evidence/date-picker/record-2026-10-17.json`. Check: review.
  - Don't: `<DatePicker mode="range" />` for check-in and check-out
  - Do: `<DatePicker mode="range" count="nights" minDays={1} />`
- `rule/date-picker-typed-for-known-days`: When people already know the day, such as a report or filing date, pass `typed`, instead of only the calendar, because a day years back takes one line of typing and a dozen presses of the month buttons. Evidence: principle heuristic: flexibility and efficiency of use; single use docs/system/examples/date-picker/typed.tsx:17; measured 11 typed forms in 4 locales read to the right day, calendar.test.tsx "a typed day is read in the locale's own order and words". Check: review.
  - Don't: `<DatePicker min="2011-11-01" max={today} />` for a report date alone
  - Do: `<DatePicker typed min="2011-11-01" max={today} />`
- `rule/date-picker-presets-in-the-picker`: When a range filters reports, filings or a dashboard, pass `presets`, such as `datePresets(today)`, instead of a row of period pills beside the field, because the presets sit beside the calendar they set, the field then names the period, and a custom range stays one press away. Evidence: principle heuristic: recognition rather than recall, a named period is read, not worked out; single use `docs/system/examples/date-picker/presets.tsx:23`, the filings filter. Check: test `date-picker.test.tsx` renders a range that matches a preset and expects the preset's name in the field.
  - Don't: `<SegmentedControl options={["7D", "30D", "QTD"]} /><DatePicker mode="range" />`
  - Do: `<DatePicker mode="range" presets={datePresets(today)} />`

### Content
- Follows `rule/writing-placeholder-not-label`.
- `rule/date-picker-placeholder-names-the-answer`: When the field has a placeholder, write what an empty field means, such as "Any date" for a filter or "Add dates" for a stay, instead of a format hint such as "MM/DD/YYYY", because the field shows the day in the reader's own words, and `typed` reads whatever order the reader types in. Evidence: app 4/4 placeholders in the examples say what empty means (`docs/system/examples/date-picker/default.tsx:18`, `docs/system/examples/date-picker/mode-range.tsx:27`); principle heuristic: match between system and the real world. Check: review.
  - Don't: `<DatePicker placeholder="MM/DD/YYYY" />`
  - Do: `<DatePicker placeholder="Any date" />`
- `rule/date-picker-stay-words`: When the range is a stay, name its ends through `labels` as check-in and check-out, instead of the default "first day" and "last day", because a guest thinks in check-in and check-out, and the footer says "Choose check-out" while it waits. Evidence: single use docs/system/examples/date-picker/mode-range.tsx:33-39; principle heuristic: match between system and the real world. Check: review.
  - Don't: `<DatePicker mode="range" count="nights" />` with the footer saying "Choose the last day"
  - Do: `<DatePicker mode="range" count="nights" labels={{ chooseStart: "Choose check-in", chooseEnd: "Choose check-out", start: "Check-in", end: "Check-out" }} />`

### Anti-slop
- `rule/date-picker-not-native-date`: When a form needs a day picked from a month, use `DatePicker` instead of an `<input type="date">` styled through `className`, because the native picker opens outside the system's tokens, shows a different calendar in every browser, and takes no `isDateDisabled`. Evidence: principle platform: the native date popup is drawn by the browser and takes no styling; app 2/2 source apps replaced theirs (`docs/research/2026-10-17-coverage.md`). Check: lint trap/native-control (scripts/check-system.mjs); review.
  - Don't: `<Input type="date" className="w-48" />`
  - Do: `<DatePicker placeholder="Choose a date" />`
- `rule/date-picker-no-glyph-of-your-own`: When composing a `DatePicker`, pass no `CalendarIcon` or chevron, because the trigger draws the calendar glyph itself (`registry/cobalt/ui/date-picker.tsx:367`) and a second one doubles it. Evidence: app 9/9 pickers in the examples pass no glyph; single use registry/cobalt/ui/date-picker.tsx:367. Check: review.
  - Don't: `<InputGroup><InputGroupAddon><CalendarIcon /></InputGroupAddon><DatePicker /></InputGroup>`
  - Do: `<DatePicker />`

### Limits
- `rule/date-picker-trigger-width`: When the field holds a range, give its `Field` at least 288px, `max-w-72`, instead of a narrower box, because a range across a year, "Dec 28, 2026 to Jan 4, 2027", and three runs of days, "Nov 10, Nov 12, and Nov 17 to 19, 2026", take up to 236px of the 238px of text room a 288px trigger leaves beside the glyph, and a narrower trigger cuts the end date with an ellipsis. Evidence: measured "Dec 28, 2026 to Jan 4, 2027" at 175px and "Nov 10, Nov 12, and Nov 17 to 19, 2026" at 236px whole in a 288px trigger with 238px for the text, `.design-system/evidence/calendar/accent-runs-2026-10-17.json`. Check: probe /stress/date-picker?data=worst.
  - Don't: `<Field className="max-w-40"><FieldControl render={<DatePicker mode="range" />} /></Field>`
  - Do: `<Field className="w-full max-w-72"><FieldControl render={<DatePicker mode="range" />} /></Field>`

## Accessibility
Rests on this registry's `Popover`, which is Base UI `Popover` from 640px up and the registry's `Sheet` (Base UI `Dialog`) below it, and on `Calendar` for the grid. The trigger is a native `<button>`; the popup is a `dialog` named by `labels.dialog`.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the trigger | focuses the trigger; the field's ring shows | the trigger | screenshot |
| Enter or Space | the trigger | opens the calendar | the picked day, or today, or the 1st | by hand |
| arrows, Home, End, Page keys | a day | as in Calendar, across both months | that day | by hand |
| Enter or Space | a day, `mode="single"` | picks it and closes | the trigger | by hand |
| Enter or Space | a day, `mode="range"` | sets the start, then the end; closes after the end from 640px up | the next day, then the trigger | by hand |
| Enter or Space | a day, `mode="multiple"` | adds it or takes it away | the day | by hand |
| Enter | a typed field | reads the day; a single day closes the popup, a range's start moves on to its end | the trigger, or the field | by hand |
| Escape | a typed field with an edit | puts the day back | the field | by hand |
| Escape | anywhere else inside the popup or sheet | closes without changing the value | the trigger | by hand |
| ArrowDown or ArrowUp | a preset | moves to the next or previous preset, wrapping | that preset | by hand |
| Enter or Space | a preset | picks its range and closes | the trigger | by hand |

Measured at 1440px and 390px, light and dark, default and pill corners (`.design-system/evidence/date-picker/record-2026-10-17.json`): focus on today after Enter; each arrow, Home, End and Page key moved focus to the expected day with the trigger's rect unchanged on every frame; focus on the trigger after the range's end and after Escape.

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| trigger | button | the `FieldLabel` through `FieldControl`, or `aria-label` | `aria-haspopup="dialog"`, `aria-expanded`, `aria-invalid`, `aria-describedby`, `disabled` | the name, the value or the placeholder, "collapsed" | test |
| popup | dialog | `aria-label` from `labels.dialog`; on a phone the sheet's visible title | none | "Choose a date, dialog" | by hand |
| grid | grid | the month title | as in Calendar | as in Calendar | by hand |
| typed fields | textbox | `labels.date`, or `labels.start` and `labels.end` | `aria-invalid` when refused | "Check-in, edit text" | by hand |
| footer line | none, `aria-live="polite"` | its text | none | "4 nights", or the reason a typed day was refused | by hand |
| presets | group | "Ranges" from `labels.presets` | each preset a button with `aria-pressed` | the name, then each preset and "pressed" for the one in the field | by hand |
| hidden inputs | none | none | `name` and the value | nothing; they carry the form value | test |

## Tokens
| Part | State | Token |
|---|---|---|
| trigger | all | `--control`, `--r-control`, `--input` at 50 percent, `--foreground` |
| trigger | empty | `--muted-foreground` |
| trigger | focus-visible | `--primary` 1px inset and 3px at 20 percent, `--t-press` |
| trigger | invalid | `--destructive` at 10 percent |
| glyph | all | `--muted-foreground`, 16px |
| popup | open | `--popover`, `--r-3xl`, `--shadow-floating`, `--pad-popup`, `--t-pop` |
| sheet | open, below 640px | the Sheet's `--popover`, top corners `--r-2xl`, `--t-sheet` |
| footer | all | text-sm `--muted-foreground`; a refusal in `--destructive` |
| preset row | hover and focus | `--accent`; the check in `--primary-ink`, the menu row's `--r-lg` |
| preset pill | phone | the Pill's `--muted`, and `--foreground` with `--background` text when on |

Measured at 1440px (`.design-system/evidence/date-picker/record-2026-10-17.json`): the trigger 36px tall at 288px whatever it holds; a range's popup 532x356px with two months (`.design-system/evidence/calendar/accent-runs-2026-10-17.json`), 4px below the trigger at its start edge, flipped above with the same 4px gap when the trigger is 60px from the bottom, and the same size on every month and in the months view; a 16px corner and 6px padding. At 390px: a bottom sheet 390px wide, days 49x44px 4px apart week from week; the calendar's title starts at 24px under the sheet's title, and its arrow buttons stand in the close button's 342 to 374px; the footer's line and Done share one row, Done 36px tall. Opening and closing fade in place from 640px up, and nothing on the page moves: the trigger and the field's description held still on every frame while a stay was picked at 1440px and 390px.

## Related
- Calendar: the month grid on its own, always in view.
- Popover: the panel the calendar opens in, and the sheet on a phone.
- Field: the label, description and error around it.
- Input: the field look it shares, and the typed fields.
- Combobox: a field that picks from a list by typing.
- InputGroup: a text field with a glyph, a unit or a button inside its box.
- DateTile: shows a date beside a booking; it picks nothing.
- Slider: a value or a range picked along a track, with its bounds typed if needed.
