# DatePicker

Supply UI 1.1.0. Actions and forms.

A field to type a date in, with a calendar to pick it from; a sheet on a phone. `mode="range"` gives a field for each end. `presets` are ready choices under the calendar: `[{ label: 'Today', value: '2026-11-15' }]`

A field to type a date in, with a calendar to pick it from. The value is "YYYY-MM-DD"; `mode="range"` gives a field for each end and the value `[start, end]`. On a phone the calendar comes up as a sheet (`presentation="auto"`). `name` sends it with the form.

## Options

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. |
| `className` | `string` |  | More classes on the outer element, for layout around it (margins, grid placement), not to restyle it. |
| `clearable` | `boolean` |  | A button that empties the field. |
| `defaultValue` | `null \| string \| [string, string]` |  | The value it starts with, when it keeps its own state (uncontrolled). |
| `endLabel` | `string` |  | In range mode: the end field's name for screen readers; "End date" (in the app's language) by default. |
| `endPlaceholder` | `string` |  | In range mode: shown while the end field is empty. |
| `id` | `string` |  | Its id, for a `<label htmlFor>` or `aria-labelledby` elsewhere. |
| `marked` | `string[]` |  | Days with something on them: they get a dot. "YYYY-MM-DD". |
| `mode` | `"single" \| "range"` |  | What is chosen: `single` (default), one day, or `range`, a start and an end (`[start, end]`) in two fields. |
| `months` | `number` |  | How many months show side by side. |
| `onValueChange` | `(value: string) => void \| (value: [string, string] \| null) => void` |  | Runs with the new choice, in the shape `mode` gives: the day (an empty string when it is cleared) or `[start, end]`. |
| `placeholder` | `string` |  | Shown while the field is empty. In range mode, for the start. |
| `presets` | `{ label: ReactNode; value: PickerValue; }[]` |  | Ready-made choices under the calendar: "Today", "Last 7 days". The tool works out the dates. |
| `selects` | `boolean` |  | Dropdowns for the month and the year instead of the title: for a birthday, or any date far from today. |
| `value` | `null \| string \| [string, string]` |  | The current value, when your state holds it (controlled); use with `onValueChange`. |

It also takes the 311 attributes of the element or UI SDK part it renders (`className`, `aria-label`, events…).

## Without React

Classes: (React only; plain HTML uses `input[type=date]`)

## CSS parts

With the CSS in parts (`/ui/css/`), it needs: `components/button.css`, `components/card.css`, `components/table.css`, `components/tabs.css`, `components/popups.css`, `components/dialog.css`, `components/icons.css`, `components/input-group.css`, `components/calendar.css`, `components/button-group-toggle.css`, `components/code-input.css`, `components/tab-bar.css`, `components/command-palette.css`, `components/prose.css`, `components/carousel-arrows.css`, `components/page-transitions.css`, `parts/carousel.css`, `parts/calendar.css`, `parts/date-time-typed-part.css`, `parts/listbox.css`, `parts/date-picker.css`, `parts/board.css`, besides the ones every page loads.

## In the examples

- When the box comes: Type or pick the day, then the part of it (https://www.supply.family/ui/#scene-delivery)

## Actions and forms: notes

**States.** Every control has rest, hover, pressed, focus (a ring, from the keyboard only), disabled and, where it applies, chosen (`data-checked`, `aria-pressed`) and invalid (`aria-invalid`, with the message under the field). Each change of look fades with `--ui-dur-fast`.

**Do**
- Give every field a visible label (`Field label=…`); a placeholder is an example, never the label.
- Keep one primary button per view; deleting is `danger` and asks first with `AlertDialog`.
- Say what went wrong under the field, in words a person can act on ("Enter a full email address").
- Use `NumberInput`, `DatePicker`, `Select` and the rest rather than a bare `<input>`: they bring the keyboard, the screen-reader names and the phone layout.

**Don't**
- Don't disable a button to say a form is incomplete without saying why next to it.
- Don't put two primary buttons side by side, or a primary button inside a menu.
- Don't use a `Switch` for something that only happens when a form is sent: that is a `Checkbox`.
