Date Picker
A segmented date field with a calendar behind a trigger, for one calendar date that the reader can type or choose.
Type the date or choose it from the calendar.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';export default function DatePickerBasic() { return ( <Field> <FieldLabel>Requested delivery date</FieldLabel> <DatePicker name="deliveryDate" /> <FieldDescription>Type the date or choose it from the calendar.</FieldDescription> </Field> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { DatePicker, DatePickerDefaultsProvider } from '@slotted/react';Typing or choosing
The field and the calendar write the same value. Type the month, day and year into the segments, or press the calendar button and choose a day; each change reports its reason: keyboard for typing and for the arrow keys in the calendar, pointer for a press on a day, clear for the clear button and blur for a date completed when the field loses focus. A two-digit year resolves through yearPivot: with the default of 20, 30 reads as 2030 and 80 as 1980.
No change yet.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { isPlainDate, plainDate, toISODate } from '@slotted/core/date';const REASONS: Record<string, string> = { keyboard: 'from the keyboard', pointer: 'pressed in the calendar', clear: 'cleared', blur: 'completed when the field lost focus',};export default function DatePickerTyping() { const [change, setChange] = useState('No change yet.'); return ( <Field> <FieldLabel>Goods received on</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 30)} onValueChange={(value, request) => { const date = isPlainDate(value) ? toISODate(value) : 'empty'; setChange(`${date}, ${REASONS[request.reason] ?? request.reason}.`); }} /> <FieldDescription>{change}</FieldDescription> </Field> );}Sizes
size sets the field and the trigger to one step of the control scale: sm for toolbars and dense tables, md for most forms, lg for sparse forms. Inside a field, an unset size follows the field.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DatePickerSizes() { return ( <Stack gap={5}> <Field> <FieldLabel>Shipped after</FieldLabel> <DatePicker size="sm" defaultValue={plainDate(2026, 9, 1)} /> </Field> <Field> <FieldLabel>Ship date</FieldLabel> <DatePicker size="md" defaultValue={plainDate(2026, 9, 30)} /> </Field> <Field> <FieldLabel>Move-in date</FieldLabel> <DatePicker size="lg" defaultValue={plainDate(2026, 11, 2)} /> </Field> </Stack> );}Variants
outline is the default frame. subtle fills the control, for a form on a tinted surface. plain draws no frame at rest, for a table cell or a toolbar, and still shows hover and focus. The calendar button keeps its icon in all three.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DatePickerVariants() { return ( <Stack gap={5}> <Field> <FieldLabel>Invoice date</FieldLabel> <DatePicker variant="outline" defaultValue={plainDate(2026, 9, 30)} /> </Field> <Field> <FieldLabel>Posting date</FieldLabel> <DatePicker variant="subtle" defaultValue={plainDate(2026, 9, 30)} /> </Field> <Field> <FieldLabel>Value date</FieldLabel> <DatePicker variant="plain" defaultValue={plainDate(2026, 10, 1)} /> </Field> </Stack> );}States
Set invalid, readOnly and disabled on the field, which passes them to the date picker; each can also be set on the date picker itself. Invalid draws the frame and the focus ring in the danger tone and sets aria-invalid. Read-only keeps the date legible and focusable. Read-only and disabled both disable the calendar button, so the calendar cannot open.
Error:The delivery date is before the order date, September 30, 2026.
Set when the order was placed.
Returns open once the order is delivered.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DatePickerStates() { return ( <Stack gap={5}> <Field invalid required> <FieldLabel>Delivery date</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 28)} /> <FieldError>The delivery date is before the order date, September 30, 2026.</FieldError> </Field> <Field readOnly> <FieldLabel>Order date</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 30)} /> <FieldDescription>Set when the order was placed.</FieldDescription> </Field> <Field disabled> <FieldLabel>Return by</FieldLabel> <DatePicker defaultValue={plainDate(2026, 10, 30)} /> <FieldDescription>Returns open once the order is delivered.</FieldDescription> </Field> </Stack> );}Earliest and latest dates
min and max bound the field and the calendar together. The calendar disables the days outside the bounds. A date typed outside the bounds stays in the field and marks the date picker invalid, so the reader sees the problem instead of losing what they typed.
Carriers book October 2026 only.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerBounds() { return ( <Field> <FieldLabel>Delivery window</FieldLabel> <DatePicker defaultValue={plainDate(2026, 10, 15)} max={plainDate(2026, 10, 31)} min={plainDate(2026, 10, 1)} /> <FieldDescription>Carriers book October 2026 only.</FieldDescription> </Field> );}Unavailable dates
isDateUnavailable receives each date and returns true for a date the reader cannot choose, such as a weekend or a holiday. The calendar disables those days, and a typed unavailable date marks the date picker invalid. Keep the rule in one function and describe it in the field’s description, so the reader knows why a day is refused.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { dayOfWeek, plainDate, toISODate, type PlainDate } from '@slotted/core/date';/** Columbus Day, Veterans Day, Thanksgiving and Christmas Day, 2026. */const HOLIDAYS = new Set(['2026-10-12', '2026-11-11', '2026-11-26', '2026-12-25']);const isClosed = (date: PlainDate) => dayOfWeek(date) === 0 || dayOfWeek(date) === 6 || HOLIDAYS.has(toISODate(date));export default function DatePickerUnavailable() { return ( <Field> <FieldLabel>Pickup date</FieldLabel> <DatePicker defaultValue={plainDate(2026, 10, 13)} isDateUnavailable={isClosed} /> <FieldDescription>The Reno dock is closed on weekends and federal holidays.</FieldDescription> </Field> );}Locale and format
locale takes a BCP 47 tag and sets the order of the segments, their separators and placeholders, the month and weekday names in the calendar, and the date in words that the calendar button announces. There is no format string: each locale writes its own shape. Unset, the locale comes from SlottedProvider in React or provideSlotted in Angular, and falls back to en-US. The value stays the same PlainDate in every locale.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';const SHIP_DATE = plainDate(2026, 9, 30);export default function DatePickerLocale() { return ( <Stack gap={5}> <Field> <FieldLabel>Ship date, United States (en-US)</FieldLabel> <DatePicker defaultValue={SHIP_DATE} locale="en-US" /> </Field> <Field> <FieldLabel>Ship date, United Kingdom (en-GB)</FieldLabel> <DatePicker defaultValue={SHIP_DATE} locale="en-GB" /> </Field> <Field> <FieldLabel>Ship date, Germany (de-DE)</FieldLabel> <DatePicker defaultValue={SHIP_DATE} locale="de-DE" /> </Field> <Field> <FieldLabel>Ship date, Japan (ja-JP)</FieldLabel> <DatePicker defaultValue={SHIP_DATE} locale="ja-JP" /> </Field> </Stack> );}First day of the week
The calendar starts the week on the day the locale uses. firstDayOfWeek overrides it with a number from 0, Sunday, to 6, Saturday, for a business whose weeks run differently from its locale.
Rosters run Monday to Sunday.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerFirstDay() { return ( <Field> <FieldLabel>Shift starts</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 30)} firstDayOfWeek={1} locale="en-US" /> <FieldDescription>Rosters run Monday to Sunday.</FieldDescription> </Field> );}Week numbers
weekNumbers adds a column of ISO 8601 week numbers to the calendar. ISO weeks start on Monday, so set firstDayOfWeek to 1 to keep each row inside one numbered week. isoWeekNumber from @slotted/core/date returns the same number for a chosen date.
Planned for week 40.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { isPlainDate, isoWeekNumber, plainDate, type PlainDate } from '@slotted/core/date';export default function DatePickerWeekNumbers() { const [date, setDate] = useState<PlainDate | null>(plainDate(2026, 9, 30)); return ( <Field> <FieldLabel>Production run</FieldLabel> <DatePicker firstDayOfWeek={1} onValueChange={(value) => setDate(isPlainDate(value) ? value : null)} value={date} weekNumbers /> <FieldDescription> {date === null ? 'No week planned.' : `Planned for week ${isoWeekNumber(date)}.`} </FieldDescription> </Field> );}Several months
months draws that many months side by side in the calendar, for dates the reader picks weeks ahead. The calendar keeps six rows per month by default (fixedWeeks), so the surface does not change height between months.
Technicians book up to eight weeks ahead.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerMonths() { return ( <Field> <FieldLabel>Installation appointment</FieldLabel> <DatePicker defaultValue={plainDate(2026, 10, 20)} months={2} /> <FieldDescription>Technicians book up to eight weeks ahead.</FieldDescription> </Field> );}Starting view
defaultView opens the calendar on the day, month or year grid. Start on year for a date that is usually years in the past, such as a date of incorporation or a birth date, so the reader does not page back month by month.
As printed on the certificate of incorporation.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerDefaultView() { return ( <Field> <FieldLabel>Date of incorporation</FieldLabel> <DatePicker defaultView="year" max={plainDate(2026, 9, 30)} /> <FieldDescription>As printed on the certificate of incorporation.</FieldDescription> </Field> );}Placement
The calendar opens below the field, aligned to its start edge. placement takes bottom, top, and either with -start or -end. It is a preference: when the calendar does not fit on that side, it opens on the other.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DatePickerPlacement() { return ( <Stack gap={5}> <Field> <FieldLabel>Opens above, from the start edge</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 30)} placement="top-start" /> </Field> <Field> <FieldLabel>Opens below, from the end edge</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 30)} placement="bottom-end" /> </Field> </Stack> );}Controlled
Pass value and update it from onValueChange in React, or bind [value] and update it from (valueChange) in Angular, when other parts of the screen depend on the date. The handler receives a PlainDate, or null once the date is cleared. Buttons outside the date picker can set the value; the field and the calendar follow.
Reminder on Wednesday, October 7, 2026.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { addDays, createDateFormat, isPlainDate, plainDate, type PlainDate,} from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);const words = createDateFormat({ locale: 'en-US' });export default function DatePickerControlled() { const [followUp, setFollowUp] = useState<PlainDate | null>(addDays(TODAY, 7)); return ( <Stack gap={4}> <Field> <FieldLabel>Follow up with Harbor Freightways</FieldLabel> <DatePicker onValueChange={(value) => setFollowUp(isPlainDate(value) ? value : null)} value={followUp} /> <FieldDescription> {followUp === null ? 'No follow-up scheduled.' : `Reminder on ${words.describe(followUp)}.`} </FieldDescription> </Field> <Inline gap={2}> <Button size="sm" tone="secondary" variant="outline" onClick={() => setFollowUp(addDays(TODAY, 7))} > In 1 week </Button> <Button size="sm" tone="secondary" variant="outline" onClick={() => setFollowUp(addDays(TODAY, 14))} > In 2 weeks </Button> <Button size="sm" tone="secondary" variant="ghost" onClick={() => setFollowUp(null)}> No follow-up </Button> </Inline> </Stack> );}An API that carries dates as ISO 8601 text, such as "2026-10-19", converts at the boundary with @slotted/core/date, which also exports the PlainDate type. parseISODate(text) returns a PlainDate or null, toISODate(date) returns 'YYYY-MM-DD', and isPlainDate(value) narrows the CalendarValue the change handler reports.
The API receives 2026-10-19.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { isPlainDate, parseISODate, toISODate } from '@slotted/core/date';export default function DatePickerIsoDate() { /* The API carries the date as text; the picker holds a PlainDate. */ const [iso, setIso] = useState('2026-10-19'); return ( <Field> <FieldLabel>Statement date</FieldLabel> <DatePicker onValueChange={(value) => setIso(isPlainDate(value) ? toISODate(value) : '')} value={parseISODate(iso)} /> <FieldDescription> {iso === '' ? 'No date sent.' : `The API receives ${iso}.`} </FieldDescription> </Field> );}Clearing
clearable adds a clear button to the field while it holds a date, and Clear to the footer of the panel. The button sets the value to null with the reason clear and returns focus to the field. With required, neither is drawn.
Clear the date to release the shipment.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerClearable() { return ( <Field> <FieldLabel>Hold shipment until</FieldLabel> <DatePicker clearable defaultValue={plainDate(2026, 10, 9)} /> <FieldDescription>Clear the date to release the shipment.</FieldDescription> </Field> );}Shortcuts
presets adds a column of shortcuts beside the calendar, as a list of labels and dates. The panel writes under each label the date it sets, offers Today before them, and adds the twelve months of the year. A value may be a function, which is resolved when the panel draws it, and a shortcut outside the bounds is unavailable. Without presets, the panel is the calendar alone. Here each shortcut sets the date and closes the panel.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { addDays, isPlainDate, plainDate, type PlainDate } from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);const PRESETS = [ { label: 'End of the quarter', value: TODAY }, { label: 'Next Monday', value: plainDate(2026, 10, 5) }, { label: 'In two weeks', value: () => addDays(TODAY, 14) },];export default function DatePickerPresets() { const [date, setDate] = useState<PlainDate | null>(TODAY); return ( <Field> <FieldLabel>Dispatch date</FieldLabel> <DatePicker onValueChange={(value) => setDate(isPlainDate(value) ? value : null)} presets={PRESETS} value={date} /> </Field> );}Footer and confirmation
The footer carries a hint and, with clearable, the Clear button. A panel with no hint, no Clear and no Apply draws no footer. footer in React and an element with slDatePickerFooter in Angular replace the hint; a refused date replaces both with the reason. confirm decides when the value changes: off, the default for one date, a press sets it and closes the panel; on, the default for a range and for several dates, the panel keeps a draft that Apply sets and that Escape or a press outside discards. Here confirm keeps one date as a draft.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerFooter() { return ( <Field> <FieldLabel>Stock count date</FieldLabel> <DatePicker confirm defaultValue={plainDate(2026, 10, 3)} footer="The warehouse closes at noon" /> <FieldDescription>The date changes when you press Apply.</FieldDescription> </Field> );}Plain dates and time zones
The value is a PlainDate, an object with year, month and day and no time or time zone, so the date the reader chose is the date your server receives. toISODate writes it as 2026-09-30, and parseISODate reads it back. timeZone changes one thing: which day the calendar marks as today. Unset, today comes from the browser’s time zone. today states the day itself, such as a business date or a day your server answers: it decides the day marked as today, the Today shortcut and the month an empty panel opens on.
Today is marked by the date in Auckland.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';import { isPlainDate, plainDate, toISODate, type PlainDate } from '@slotted/core/date';export default function DatePickerTimeZones() { const [date, setDate] = useState<PlainDate | null>(plainDate(2026, 9, 30)); return ( <Stack gap={4}> <Field> <FieldLabel>Settlement date, Auckland desk</FieldLabel> <DatePicker onValueChange={(value) => setDate(isPlainDate(value) ? value : null)} timeZone="Pacific/Auckland" value={date} /> <FieldDescription>Today is marked by the date in Auckland.</FieldDescription> </Field> <Text size="sm" tone="muted"> {date === null ? 'Value: null' : `Value: ${JSON.stringify(date)}, sent as ${toISODate(date)}`} </Text> </Stack> );}In a form
name adds a hidden input that submits the date as an ISO string, such as 2026-10-14, whether it was typed or chosen. In Angular, the date picker is a form control: formControlName, formControl and ngModel bind the value, Validators.required applies to it, and the date picker reports slottedDateRange for a date outside min and max and slottedDateUnavailable for a refused date. In React, the date stays in your state and you validate it on submit. Submit without a date to see the required error, type a date in September to see the bound error, then reset.
import { useState } from 'react';import type { SubmitEvent } from 'react';import { Button } from '@slotted/react/button';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldError, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';import { compareDate, isPlainDate, plainDate, type PlainDate } from '@slotted/core/date';const EARLIEST = plainDate(2026, 10, 1);export default function DatePickerForm() { const [date, setDate] = useState<PlainDate | null>(null); const [submitted, setSubmitted] = useState(false); const [saved, setSaved] = useState<string | null>(null); const error = date !== null && compareDate(date, EARLIEST) < 0 ? 'Choose October 1, 2026 or later.' : submitted && date === null ? 'Choose a delivery date.' : ''; const submit = (event: SubmitEvent<HTMLFormElement>) => { event.preventDefault(); setSubmitted(true); const value = new FormData(event.currentTarget).get('deliveryDate'); const valid = date !== null && compareDate(date, EARLIEST) >= 0; setSaved(valid ? `Delivery booked for ${String(value)}.` : null); }; const reset = () => { setDate(null); setSubmitted(false); setSaved(null); }; return ( <form noValidate onSubmit={submit} onReset={reset}> <Stack gap={5}> <Field required invalid={error === '' ? undefined : true}> <FieldLabel>Delivery date</FieldLabel> <DatePicker min={EARLIEST} name="deliveryDate" onValueChange={(value) => setDate(isPlainDate(value) ? value : null)} value={date} /> <FieldError live="polite" reserve> {error} </FieldError> </Field> <Inline gap={3} align="center"> <Button type="submit">Book delivery</Button> <Button type="reset" tone="secondary" variant="outline"> Reset </Button> {saved && ( <Text size="sm" tone="muted"> {saved} </Text> )} </Inline> </Stack> </form> );}Keyboard and the trigger’s name
Alt+ArrowDown opens the calendar from the field; Enter or Space on the calendar button opens it too. Opening moves focus to the chosen day, or to today when no date is set, and Tab and Shift+Tab cycle through the shortcuts, the calendar and the footer until the panel closes. Ctrl+Enter applies a draft. The arrow keys move between days, PageUp and PageDown move by a month, Shift with either moves by a year, and Enter or Space chooses the focused day. Escape closes the calendar and returns focus to the calendar button; while the calendar shows the month or year grid, Escape first returns to the day grid. The calendar button’s accessible name carries the chosen date, so a screen reader announces it when focus returns. messages replaces that name: choose while no date is set and change, with the date in its {date} slot, once one is. onOpenChange in React and (openChange) in Angular report why the calendar opened or closed.
Focus the field and press Alt+ArrowDown.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';export default function DatePickerKeyboard() { const [last, setLast] = useState('Focus the field and press Alt+ArrowDown.'); return ( <Field> <FieldLabel>Dispatch date</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 30)} messages={{ choose: 'Choose dispatch date', change: 'Change dispatch date, {date}' }} onOpenChange={(open, request) => setLast(`${open ? 'Opened' : 'Closed'} by ${request.reason}.`) } /> <FieldDescription>{last}</FieldDescription> </Field> );}Narrow screens
Under 480 pixels on a touch screen, the calendar opens as a modal sheet that slides up from the bottom of the viewport over a scrim, instead of a popover under the field. A press on the scrim, Escape, the platform’s way back or a pull on the grip closes it, and focus returns to the trigger. Under 760 pixels, on any screen, the panel is one column: one month, and the shortcuts in a row above the footer. The positioner carries data-presentation="sheet" for the sheet.
import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { plainDate } from '@slotted/core/date';const PRESETS = [ { label: 'Pickup', value: plainDate(2026, 9, 28) }, { label: 'Promised', value: plainDate(2026, 9, 30) },];export default function DatePickerNarrow() { return ( <Field> <FieldLabel>Proof of delivery date</FieldLabel> <DatePicker presets={PRESETS} /> </Field> );}Focus and open from code
The date picker’s handle has focus(), which puts focus on the first segment of the field, and open() and close() in React, named openSurface() and closeSurface() in Angular. Opening from code moves focus into the calendar, as the calendar button does. Reach it with ref in React and #picker="slDatePicker" in Angular, for a button elsewhere on the screen that starts an edit.
import { useRef } from 'react';import { Button } from '@slotted/react/button';import { DatePicker, type DatePickerHandle } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DatePickerFocusAndOpen() { const picker = useRef<DatePickerHandle>(null); return ( <Stack gap={4}> <Field> <FieldLabel>Contract renewal date</FieldLabel> <DatePicker ref={picker} defaultValue={plainDate(2027, 3, 31)} /> </Field> <Inline gap={2}> <Button size="sm" tone="secondary" variant="outline" onClick={() => picker.current?.focus()} > Edit date </Button> <Button size="sm" tone="secondary" variant="outline" onClick={() => picker.current?.open()}> Open calendar </Button> </Inline> </Stack> );}Defaults for a section
DatePickerDefaultsProvider in React and provideDatePickerDefaults in Angular set size, variant, placement, confirm, timeZone, today and calendar once for every date picker under them, such as a filter panel. A value set on one date picker still wins.
import { DatePicker, DatePickerDefaultsProvider } from '@slotted/react/date-picker';import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { plainDate } from '@slotted/core/date';export default function DatePickerDefaults() { return ( <DatePickerDefaultsProvider size="sm" variant="subtle" placement="bottom-end"> <Stack gap={4}> <Field> <FieldLabel>Posted after</FieldLabel> <DatePicker defaultValue={plainDate(2026, 9, 1)} /> </Field> <Field> <FieldLabel>Due before</FieldLabel> <DatePicker defaultValue={plainDate(2026, 10, 31)} /> </Field> </Stack> </DatePickerDefaultsProvider> );}Ship date in business days
The earliest ship date is two business days after the order, weekends and holidays are unavailable, and the latest date is forty business days out. One isBusinessDay function feeds isDateUnavailable and the count in the description, so the calendar and the text agree.
Ships Friday, October 2, 2026, 2 business days after the order.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { addDays, compareDate, createDateFormat, dayOfWeek, isPlainDate, plainDate, toISODate, type PlainDate,} from '@slotted/core/date';const ORDERED = plainDate(2026, 9, 30);const HOLIDAYS = new Set(['2026-10-12', '2026-11-11', '2026-11-26', '2026-12-25']);const words = createDateFormat({ locale: 'en-US' });const isBusinessDay = (date: PlainDate) => dayOfWeek(date) !== 0 && dayOfWeek(date) !== 6 && !HOLIDAYS.has(toISODate(date));const addBusinessDays = (from: PlainDate, count: number) => { let date = from; for (let added = 0; added < count;) { date = addDays(date, 1); if (isBusinessDay(date)) added += 1; } return date;};const businessDaysBetween = (from: PlainDate, to: PlainDate) => { let count = 0; for (let date = addDays(from, 1); compareDate(date, to) <= 0; date = addDays(date, 1)) { if (isBusinessDay(date)) count += 1; } return count;};const EARLIEST = addBusinessDays(ORDERED, 2);const LATEST = addBusinessDays(ORDERED, 40);export default function DatePickerShippingDate() { const [date, setDate] = useState<PlainDate | null>(EARLIEST); return ( <Field required> <FieldLabel>Ship date</FieldLabel> <DatePicker isDateUnavailable={(day) => !isBusinessDay(day)} max={LATEST} min={EARLIEST} onValueChange={(value) => setDate(isPlainDate(value) ? value : null)} value={date} /> <FieldDescription> {date === null ? 'Orders ship 2 to 40 business days after they are placed.' : `Ships ${words.describe(date)}, ${businessDaysBetween(ORDERED, date)} business days after the order.`} </FieldDescription> </Field> );}Invoice due date from payment terms
The due date follows the invoice date and the payment terms: Net 30 adds 30 days to the invoice date with addDays. The due date is a read-only date picker with a controlled value, so the reader sees the date in the same format as the invoice date and cannot edit it.
Payment is due Friday, October 30, 2026.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from '@slotted/react/select';import { Stack } from '@slotted/react/stack';import { addDays, createDateFormat, isPlainDate, plainDate, type PlainDate,} from '@slotted/core/date';const TERMS = [ { value: 'receipt', label: 'Due on receipt', days: 0 }, { value: 'net-15', label: 'Net 15', days: 15 }, { value: 'net-30', label: 'Net 30', days: 30 }, { value: 'net-60', label: 'Net 60', days: 60 },];const words = createDateFormat({ locale: 'en-US' });export default function DatePickerInvoiceDue() { const [issued, setIssued] = useState<PlainDate | null>(plainDate(2026, 9, 30)); const [terms, setTerms] = useState('net-30'); const days = TERMS.find((option) => option.value === terms)?.days ?? 0; const due = issued === null ? null : addDays(issued, days); return ( <Stack gap={5}> <Field required> <FieldLabel>Invoice date</FieldLabel> <DatePicker onValueChange={(value) => setIssued(isPlainDate(value) ? value : null)} value={issued} /> </Field> <Field> <FieldLabel>Payment terms</FieldLabel> <Select items={TERMS} onValueChange={(next) => { if (typeof next === 'string') setTerms(next); }} value={terms} > <SelectTrigger> <SelectValue /> </SelectTrigger> <SelectContent> {TERMS.map((option) => ( <SelectItem key={option.value} value={option.value}> {option.label} </SelectItem> ))} </SelectContent> </Select> </Field> <Field readOnly> <FieldLabel>Due date</FieldLabel> <DatePicker value={due} /> <FieldDescription> {due === null ? 'Set the invoice date first.' : `Payment is due ${words.describe(due)}.`} </FieldDescription> </Field> </Stack> );}Report date with closing shortcuts
A balance sheet runs as of one closing date. Shortcuts offer the closing dates finance uses most, and max stops the reader at today. For a report period with a start and an end, use the date range picker instead.
Balances close at the end of Monday, August 31, 2026.
import { useState } from 'react';import { DatePicker } from '@slotted/react/date-picker';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { createDateFormat, isPlainDate, plainDate, type PlainDate } from '@slotted/core/date';const TODAY = plainDate(2026, 9, 30);const PRESETS = [ { label: 'End of last month', value: plainDate(2026, 8, 31) }, { label: 'End of last quarter', value: plainDate(2026, 6, 30) }, { label: 'End of fiscal 2025', value: plainDate(2025, 12, 31) },];const words = createDateFormat({ locale: 'en-US' });export default function DatePickerReportDate() { const [asOf, setAsOf] = useState<PlainDate | null>(plainDate(2026, 8, 31)); return ( <Field> <FieldLabel>Balance sheet as of</FieldLabel> <DatePicker max={TODAY} onValueChange={(value) => setAsOf(isPlainDate(value) ? value : null)} presets={PRESETS} value={asOf} /> <FieldDescription> {asOf === null ? 'Choose the closing date of the report.' : `Balances close at the end of ${words.describe(asOf)}.`} </FieldDescription> </Field> );}Accessibility
| Key | Effect | Focus |
|---|---|---|
| Alt+ArrowDown | open | — |
| Escape | close | trigger |
| Tab | contained | — |
- The trigger says aria-haspopup="dialog" and its name carries the value written, which is where focus returns when the panel closes.
- The panel is a dialog with its Tab wrapped, and each grid inside it is one stop.
- Escape discards the draft and returns focus to the trigger. Ctrl+Enter applies from anywhere in the panel.
- The footer’s hint is a status region, so the reason Apply is off is spoken as well as drawn.
- Alt+ArrowDown opens the panel and takes focus to the chosen day.
- Escape walks the calendar’s view down before it closes the panel, so a reader in the years is not thrown out of it.
API
DatePicker
Props
valuePlainDate | DateRange | PlainDate[] | null- The value held, which depends on selectionMode. Present means the consumer owns it. Under granularity="month", a PlainYearMonth.
defaultValuePlainDate | DateRange | PlainDate[] | nullDefaultnull- What it starts from, and returns to on a form reset. Read once.
granularity'day' | 'month'Defaultday- What a choice is.
selectionMode'single' | 'range' | 'multiple'Defaultsingle- How many dates the value holds.
monthsnumberDefault1- How many months the panel shows. One below 760 pixels.
defaultView'day' | 'month' | 'year'Defaultday- The view the calendar opens on.
minPlainDate- The earliest accepted date.
maxPlainDate- The latest accepted date.
isDateUnavailable(date: PlainDate) => boolean- Refuses particular dates.
presetsreadonly PickerPreset<CalendarValue>[]- The consumer’s own shortcuts, after Today. Without any, the panel is the month alone.
confirmbooleanDefault off for one date- Whether the panel keeps a draft until Apply.
weekNumbersbooleanDefaultfalse- Draws the ISO week number; in a run, a press on it chooses the week.
fixedWeeksbooleanDefaulttrue- Six rows whatever the month needs, with one month.
firstDayOfWeeknumberDefault the locale’s- 0 is Sunday.
yearPivotnumber- How a two-digit typed year resolves.
calendar'gregory'Defaultgregory- The calendar system.
namestring- The name a form posts the date under.
invalidboolean- Stated by the consumer; a refused date is invalid without it.
openboolean- Whether the panel is showing. Present means the consumer owns it.
defaultOpenbooleanDefaultfalse- Whether it starts open when nobody else says. Read once.
placement'bottom-start' | 'bottom' | 'bottom-end' | 'top-start' | 'top' | 'top-end'Defaultbottom-start- Where the panel opens, before the positioner has read the room.
size'sm' | 'md' | 'lg'Defaultmd- The height of the control. The field around it answers when the picker does not.
variant'outline' | 'subtle' | 'plain'Defaultoutline- How the control draws its frame.
localestringDefault the language in force- BCP 47. Writes the field, the panel and the trigger’s name.
timeZonestringDefault the runtime’s- Which zone answers "what is now".
todayPlainDateDefault the clock’s- The day it is: the mark of today, Today, and the month an empty panel opens on.
disabledboolean- Answers no key and no press.
readOnlyboolean- Readable and not changeable.
requiredboolean- The form needs a value.
clearablebooleanDefaultfalse- Draws a clear on the control and in the panel, unless required.
messagesPartial<DatePickerMessages>- Words laid over the language in force: the trigger’s two names, and what is said of a refused date.
Events
| Name | Payload | When |
|---|---|---|
onValueChange | (value: CalendarValue, request: ChangeRequest<CalendarValue>) | Before the value moves, and cancellable: from a key in the field, from a press, from Apply, from Clear. |
onOpenChange | (open: boolean, request: ChangeRequest<boolean>) | Before the panel opens or closes, with the reason. |
Composition
DatePickerDefaultsProvidercomponent- On applicationSets calendar, confirm, placement, size, timeZone, today and variant once.
footerReactNodeDefault the page keys- What the footer says when nothing is wrong.
render(props: DatePickerRootProps) => ReactNode- Substitutes the element the root renders.
refRef<DatePickerHandle>- focus(), open() and close().
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div, or the element render returns | Yes | The frame of the picker. Carries data-ui="date-picker", data-size, data-variant, data-calendar, data-open and the state attributes. |
control | div | Yes | The box the panel hangs from, around the field and the trigger. |
trigger | button | Yes | The button that opens the panel. It says aria-haspopup="dialog", and its name carries the date written. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every date picker inside it.
Date Picker tokens
| Token | Default |
|---|---|
--slotted-date-picker-invalid-focus-ring-color | var(--slotted-focus-ring-color-invalid, Highlight) |
--slotted-date-picker-radius | var(--slotted-control-radius, 4px) |
--slotted-date-picker-trigger-active-background | var(--slotted-tone-secondary-subtle-active) |
--slotted-date-picker-trigger-color | var(--slotted-text-muted, GrayText) |
--slotted-date-picker-trigger-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-date-picker-trigger-size | min( calc(var(--_icon-size) + 2 * var(--slotted-space-2, 0.25rem)), calc( var(--_height) - var(--slotted-control-border-width, 1px) * 2 - var(--slotted-space-2, 0.25rem) ) ) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-control-border-width | var(--slotted-border-width-thin) |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-color-invalid | Set per scheme by the theme |
--slotted-focus-ring-offset | var(--slotted-border-width-thick) |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-space-2 | 0.25rem |
--slotted-target-comfortable | 44px |
--slotted-target-min | 24px |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |