Date Picker
Field-styled button that opens a Calendar in a Popover, focused on the picked day. Single or range, presets such as Last 7 days, closes once the pick is complete, and submits ISO dates through a hidden input. Works inside Field.
"use client";import { DatePicker } from "@/components/ui/date-picker";import { Field } from "@/components/ui/field";const today = new Date();const ago = (days: number) => new Date(today.getFullYear(), today.getMonth(), today.getDate() - days);// Submits period=2026-10-03/2026-10-09 with the form.export function ReportFilters() { return ( <Field label="Report period"> <DatePicker mode="range" name="period" max={today} presets={[ { label: "Last 7 days", value: { from: ago(6), to: today } }, { label: "Last 30 days", value: { from: ago(29), to: today } }, ]} /> </Field> );}<DatePicker>
Field-styled button that opens a Calendar in a Popover, focused on the picked day. A single date closes on pick; a range closes once both ends are set. Optional presets, form-ready.
aria-describedbystringIds of hint or error text; Field fills it in.
aria-invalidbooleanError styling; Field sets it from
error.aria-labelstringAccessible name when there is no visible label.
defaultValueDate | DateRange | nullDay or range at first render (uncontrolled).
disabledbooleanBlocks opening.
idstringPair with <Label htmlFor>, or let <Field> fill it in.
isDisabled(date: Date) => booleanExtra rule, e.g. weekends off. Client-only (a function).
localestringBCP 47 locale for the button text and the calendar.
maxDateLatest selectable day.
minDateEarliest selectable day.
mode"single" | "range""single": pick one day. "range": pick a start, then an end.
namestringSubmits ISO through a hidden input:
2026-10-21, or2026-10-03/2026-10-09for a range.onValueChange((date: Date) => void) | ((range: DateRange) => void)Called with the picked day, or with the range once both ends are set.
placeholderstringButton text when nothing is picked.
presetsPreset<Date>[] | Preset<DateRange>[]Shortcuts beside the grid, e.g. Today, or Last 7 days for a range. Readers reach for these first.
requiredbooleanForm submit needs a date.
valueDate | DateRange | nullControlled day, or
{ from, to }in range mode; null = nothing picked.weekStartsOn0 | 1 | 2 | 3 | 4 | 5 | 60 is Sunday, 6 is Saturday. Default 1 (Monday, ISO).
| Prop | Type | Default |
|---|---|---|
aria-describedbyIds of hint or error text; Field fills it in. | string | — |
aria-invalidError styling; Field sets it from | boolean | — |
aria-labelAccessible name when there is no visible label. | string | — |
defaultValueDay or range at first render (uncontrolled). | Date | DateRange | null | — |
disabledBlocks opening. | boolean | — |
idPair with <Label htmlFor>, or let <Field> fill it in. | string | — |
isDisabledExtra rule, e.g. weekends off. Client-only (a function). | (date: Date) => boolean | — |
localeBCP 47 locale for the button text and the calendar. | string | — |
maxLatest selectable day. | Date | — |
minEarliest selectable day. | Date | — |
mode"single": pick one day. "range": pick a start, then an end. | "single" | "range" | — |
nameSubmits ISO through a hidden input: | string | — |
onValueChangeCalled with the picked day, or with the range once both ends are set. | ((date: Date) => void) | ((range: DateRange) => void) | — |
placeholderButton text when nothing is picked. | string | — |
presetsShortcuts beside the grid, e.g. Today, or Last 7 days for a range. Readers reach for these first. | Preset<Date>[] | Preset<DateRange>[] | — |
requiredForm submit needs a date. | boolean | — |
valueControlled day, or | Date | DateRange | null | — |
weekStartsOn0 is Sunday, 6 is Saturday. Default 1 (Monday, ISO). | 0 | 1 | 2 | 3 | 4 | 5 | 6 | — |
- type Preset
- { label: string; value: Value }
* required. Every component also takes className.