DatePicker
A labelled date field that opens a Calendar popover; accepts Dates or ISO strings. @startingPoint section="Date & time" subtitle="Date field with calendar popover" viewport="320x120"
Signature
Density
Viewport
Theme and light/dark are set in the top barWhen to use
A labelled date field that opens a Calendar popover; accepts Dates or ISO strings.
Accessibility
Keyboard-navigable grid (arrow keys move days, PageUp/PageDown move months). The selected date is announced; the field has a clear label.
Install and import
npx shadcn@latest add @prism/date-picker
import { DatePicker } from '@/components/prism/DatePicker';
In a no-build prototype, read it from the bundle instead: const { DatePicker } = window.PrismDesignSystem_39d121;
Props
| Prop | Type | Required | Description |
|---|---|---|---|
label | React.ReactNode | — | |
description | React.ReactNode | — | |
value | T | null | — | Controlled value: a Date or "YYYY-MM-DD"; null for none. |
defaultValue | T | null | — | Initial value (uncontrolled): a Date or "YYYY-MM-DD". |
onChange | (date: T | null) => void | — | Fired with the chosen date in the same form as value/defaultValue (or as valueFormat says), and null when cleared. |
valueFormat | "iso" | "date" | — | Force onChange's type: "iso" ("YYYY-MM-DD") or "date". Default: ISO if any date prop (value, defaultValue, minDate, maxDate, defaultFocusedValue) is a string, else Date. Set it when the field starts empty with no other date prop. |
placeholder | string | — | |
minDate | DateInput | — | |
maxDate | DateInput | — | |
defaultFocusedValue | DateInput | — | The month the calendar opens on when there's no value (e.g. "2008-01-01" for a birth date). |
showMonthYearPicker | boolean | — | Month and year selects in the calendar header. Default true. |
locale | string | — | BCP 47 locale. Formats the shown date (default "en-GB": fixed, so server and browser render the same text) and, when set, gives the calendar that locale's month names, weekday names and first day of the week. |
weekStartsOn | 0 | 1 | 2 | 3 | 4 | 5 | 6 | — | First day of the week in the calendar, 0 (Sunday) to 6 (Saturday). Default: the locale's own when locale is set, otherwise Monday. |
formatOptions | Intl.DateTimeFormatOptions | — | Intl.DateTimeFormat options for the shown date. Default { year: "numeric", month: "short", day: "numeric" }. |
isClearable | boolean | — | Show a × that clears the value (onChange(null)). |
isRequired | boolean | — | Blocks native form submit while empty. |
isInvalid | boolean | — | |
errorMessage | React.ReactNode | — | Shown (and announced) when isInvalid. |
name | string | — | Form field name: the ISO date submits natively. |
form | string | — | Id of the form to submit with, when the picker sits outside it. |
isDisabled | boolean | — | |
isLabelHidden | boolean | — | Keep label for screen readers only (e.g. a date shown between ‹ › day arrows). |
id | string | — | Names the field when there is no label; the chosen date is read after it. |
width | "xs" | "sm" | "md" | "lg" | "full" | — | Maximum width: "xs" (8rem) | "sm" (12rem) | "md" (20rem) | "lg" (36rem) | "full" (default). A cap, not a fixed width — it still shrinks on a phone or in a narrow FormRow column; the label and messages follow it. Sizes are the --field-width-* tokens. |
className | string | — |