Date picker
In code: DatePicker
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.
Preview
Use
import { DatePicker, Field, Stack } from '@/components/ui';
<Stack>
<Field label="Delivery">
<DatePicker defaultValue="2026-11-26" locale="en-GB" weekStartsOn={1} clearable />
</Field>
<Field label="Stay">
<DatePicker mode="range" defaultValue={['2026-12-18', '2026-12-22']} locale="en-GB" weekStartsOn={1} />
</Field>
</Stack>Options
| Option | Type | 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 draws: className, aria-label, events and the rest.
Without React
The same look on any HTML, with the classes (React only; plain HTML uses input[type=date]).
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/button.csscomponents/card.csscomponents/table.csscomponents/tabs.csscomponents/popups.csscomponents/dialog.csscomponents/icons.csscomponents/input-group.csscomponents/calendar.csscomponents/button-group-toggle.csscomponents/code-input.csscomponents/tab-bar.csscomponents/command-palette.csscomponents/prose.csscomponents/carousel-arrows.csscomponents/page-transitions.cssparts/carousel.cssparts/calendar.cssparts/date-time-typed-part.cssparts/listbox.cssparts/date-picker.cssparts/board.cssIn the examples
Small screens made with it and the rest of the kit. They work: click, type and choose in them.
Actions and forms: states, do and don’t
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' }].
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
dangerand asks first withAlertDialog. - Say what went wrong under the field, in words a person can act on ("Enter a full email address").
- Use
NumberInput,DatePicker,Selectand 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
Switchfor something that only happens when a form is sent: that is aCheckbox.