This page as markdown: /date-picker.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

DatePicker

Status: stable

Date, date-range, date-and-time or time picker: a field-shaped trigger (the Input / SelectTrigger shell) opens a Popover holding Sable's Calendar. With granularity="day" selecting a day fires onValueChange and closes; granularity="minute" adds an hour + minute row of Selects and keeps the time-of-day when the day changes; granularity="time" is that row alone; mode="range" picks a start and an end day. With a name it submits its value in a form.

Keywords: date picker, due date, property row, inspector, calendar, date input, date time picker, date range picker, range, time picker, time field, time, schedule, form

Usage

Use DatePicker when users need to choose one date — or, with granularity="minute", one date and time; with granularity="time", a time of day; with mode="range", a start and an end day — from a compact control.

Best practices

Props

Name Type Default Description
mode "single" | "range" "single" One date, or a { from, to } range. In range mode the first pick sets the start, the second the end (in either order) and closes the popover; the value changes once, on the second pick, so dismissing after one pick keeps the range that was there; value, defaultValue and onValueChange take a DateRange (exported), and granularity is always "day".
value Date | DateRange — The selected date (controlled), or the { from, to } range under mode="range" (to is unset while only the start is picked). When absent, the trigger shows a muted placeholder.
defaultValue Date | DateRange — Initial value when uncontrolled (no value prop).
onValueChange ((date: Date | undefined) => void) | ((range: DateRange | undefined) => void) — Fired when the day is chosen or cleared, and under granularity="minute" / "time" when the hour or minute changes. With granularity="day" it also closes the popover. In range mode it fires on both picks: with only from after the first, with both after the second.
onChange (date: Date | undefined) => void — Deprecated alias for onValueChange, kept for backwards compatibility. Both fire when set; prefer onValueChange.
granularity "day" | "minute" | "time" "day" What the picker chooses. "minute" adds an hour + minute row and keeps the popover open so day and time can be set in any order. "time" is the hour + minute row alone, with no calendar: the value is a Date that keeps its day (today when there was none).
minuteStep number 5 Minute increment for the time row (granularity="minute" or "time").
defaultTime string "00:00" Time-of-day shown and applied while nothing is selected yet, as 24h "HH:mm" — the first day pick lands on this time instead of midnight (granularity="minute" or "time").
placeholder string "Pick a date" ("Pick date & time" for minute, "Pick a time" for time, "Pick a date range" in range mode) Trigger label shown when no date is selected.
disabled boolean — Disable the trigger and block selection.
readOnly boolean — Show the value without letting it change: the popover does not open, and the submitted value is not validated.
name string — Name of the submitted value. A visually hidden input carries it into FormData: yyyy-MM-dd for a day, yyyy-MM-ddTHH:mm (local, the datetime-local format) for a minute, HH:mm for a time, and an ISO 8601 interval yyyy-MM-dd/yyyy-MM-dd for a range (empty until both ends are picked). Empty when nothing is selected. It reaches native FormData and onSubmit, not Form's onFormSubmit values object, which lists Base UI controls only.
form string — The id of the
the value belongs to, when the picker sits outside it.
required boolean — A value is needed before the form submits: the trigger is aria-required, and a native or Sable Form submit is blocked while empty, with focus moved to the trigger. A wrapping sets it.
minDate Date — Earliest selectable day (inclusive). Earlier days are disabled and navigation is bounded.
maxDate Date — Latest selectable day (inclusive). Later days are disabled and navigation is bounded.
size "md" | "sm" | "xs" "md" The trigger's rung. md is the form field beside Input and Select. sm is md one rung down, the same raised field: a date filter in a toolbar beside an sm SelectTrigger and sm buttons. xs is the property-grid rung (24px in a workspace): an inset panel-field well with no border, the same shape as SelectTrigger size="xs" and ScrubField on the neighbouring rows of an inspector — use it for a due date in a PropertyRow instead of a native date input.
locale Locale (date-fns) — The date-fns locale for the calendar (month and weekday names, first day of the week) and for the trigger's label, so both speak one language. Without it both are English (en-US), identical on the server and the client. import { de } from "date-fns/locale".
formatOptions Intl.DateTimeFormatOptions — How the trigger writes the chosen date, as Intl.DateTimeFormat options in locale (en-US without one) — { month: "short", day: "numeric" } for "Oct 23" where the rest of a list writes dates that way. Omitted: "Oct 23, 2026" (with "at 14:30" under granularity="minute").
timeLabel string "Time" Accessible name of the time row's group.
hourLabel string "Hour" Accessible name of the hour Select.
minuteLabel string "Minute" Accessible name of the minute Select.
className string — Extra classes merged onto the trigger.
ref / id / aria-* / … button attributes — ref and every other button attribute are forwarded to the trigger, so a wrapping Field ties its label to the picker and announces its description and error, and a ref can focus it. Pass the aria attributes yourself only when labelling the picker without a Field.

Tokens used

primary, primary-foreground, accent, accent-foreground, foreground, muted-foreground, popover, popover-foreground, border, field-border, field, ring

Accessibility

Related

Examples

In an inspector row

import { DatePicker, PanelSection, PropertyRow } from "@sableui/react"

<PanelSection title="Properties">
	<PropertyRow label="Due date">
		<DatePicker size="xs" aria-label="Due date" value={due} onValueChange={setDue} formatOptions={{ month: "short", day: "numeric" }} />
	</PropertyRow>
</PanelSection>

Controlled

import { DatePicker } from "@sableui/react"

const [date, setDate] = useState<Date>()
<DatePicker value={date} onValueChange={setDate} />

Custom placeholder

import { DatePicker } from "@sableui/react"

<DatePicker placeholder="Schedule for…" value={date} onValueChange={setDate} />

Date and time

import { DatePicker } from "@sableui/react"

const [start, setStart] = useState<Date>()
<DatePicker granularity="minute" value={start} onValueChange={setStart} minDate={new Date()} defaultTime="09:00" minuteStep={15} />

Date range

import { DatePicker, type DateRange } from "@sableui/react"

const [stay, setStay] = useState<DateRange>()
<DatePicker mode="range" value={stay} onValueChange={setStay} minDate={new Date()} placeholder="Check-in – check-out" />

In a form

import { Button, DatePicker, Field, Form } from "@sableui/react"

<Form onSubmit={(event) => { event.preventDefault(); save(new FormData(event.currentTarget)) }}>
	<Field label="Check-in" required>
		<DatePicker name="checkin" minDate={new Date()} />
	</Field>
	<Field label="Opens at">
		<DatePicker name="opens" granularity="time" minuteStep={15} defaultTime="09:00" />
	</Field>
	<Button type="submit">Book</Button>
</Form>

Localised (de from date-fns/locale)

import { DatePicker } from "@sableui/react"

<DatePicker locale={de} value={date} onValueChange={setDate} placeholder="Datum wählen" />

Disabled

import { DatePicker } from "@sableui/react"

<DatePicker disabled />

Bounded (no past dates)

import { DatePicker } from "@sableui/react"

<DatePicker value={date} onValueChange={setDate} minDate={new Date()} />