App components / Date pickers
Date picker
A field that opens a calendar on a tray: one month for a date, or presets and two months for a range. Picks wait in the tray until Apply, with what you picked on the strip beside it.
MembersReact · Vue · HTMLFigma: Date pickers
Code
The component itself, ready to drop into your project. Switch between React, Vue and plain HTML; every version uses the same Tailwind classes on Ochre's tokens.
NW-118 ships on this day.
Installation
Examples
Range
Presets on the left, two months on the right, the range so far on the strip below.
Sizes and states
S to XXL, Placeholder and Filled. Each opens the same tray.
Motion
Built on Ochre's ease-out curves. With reduced motion switched on, everything still works, it just doesn't move.
01The tray opens from the field's corner and fades out a little quicker than it arrived.
02The field takes the accent border and halo while the tray is open.
03Inside, the days slide between months and a picked day pops in.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| mode | "single" | "range" | "single" | A month and Apply, or presets on the left and two months. |
| value / defaultValue / onValueChange | Date | null, (day) => void | – | Single mode. onValueChange runs on Apply. |
| range / defaultRange / onRangeChange | { start, end }, (range) => void | – | Range mode. onRangeChange runs on Apply. |
| presets | { label, range: (today) => { start, end } }[] | – | Range mode's list. Custom is added at the end and marked when nothing matches. |
| size | "s" | "m" | "l" | "xl" | "xxl" | "m" | The Date input's Size axis: 32 to 64 pixels, matching Input. |
| placeholder | string | "Pick a date" | The Placeholder state. |
| open / defaultOpen / onOpenChange | boolean, (open) => void | – | The Open state: accent border and the tray showing. |
| today / min / max / isDateDisabled | Date, Date, Date, (day) => boolean | – | Passed to the calendar. |
| name | string | – | Adds a hidden input with yyyy-mm-dd (range: name and name-end) for forms. |
| invalid / disabled | boolean | – | Red border and halo; or greyed. Field sets invalid and the id for you. |
Usage
Use it for
- A date or a range in a form: due dates, delivery, leave, a report's period.
- Anywhere the field should line up with Inputs and Selects on the same size ladder.
Avoid
- Dates people know by heart, like a birthday: an Input with dd/mm/yyyy is quicker.
- Ranges above a chart: the Relative range or Range with presets read better there.