Skip to content
Protocore Design Systemv1.6.9

/// Inputs

DatePicker

Sunken field showing a formatted date that opens a Calendar in a raised overlay for point-and-click selection.

import { DatePicker } from "@protocore/pds";
View as Markdown

Basics

An Input-styled trigger shows the selected date (formatted with Intl.DateTimeFormat) and a calendar glyph; clicking opens the month grid in a popover. Controllable via value / defaultValue / onValueChange.

In a Field, bounded & clearable

Wrap it in a Field for a label and hint. Constrain selection with min / max, and set clearable to expose a reset affordance once a date is chosen.

Within the next 60 days.

Custom format

Pass format as Intl.DateTimeFormatOptions (or a formatter function) to control how the field renders — e.g. a full weekday, or a compact numeric form.

When to use it

Use DatePicker for choosing a single date visually — a delivery date, a publish date — where seeing the surrounding month helps. When the field must be keyboard- and screen-reader-first (or filled fast from memory), pair it with, or swap it for, DateInput. For a start/end window use DateRangePicker. When the grid should stay inline rather than behind a field, use Calendar directly.

Usage

Do

  • Give the trigger an accessible name via a `Field` label or `aria-label`.
  • Set `min` / `max` to the valid window so out-of-range days can't be picked.
  • Offer `DateInput` alongside it for keyboard-first users entering known dates.
  • Pass a `locale` so the formatted value matches the rest of the UI.

Don't

  • Don't rely on the picker alone for a distant date — a birthday is faster to type.
  • Don't leave the trigger unlabelled when no visible field label wraps it.
  • Don't reformat the value yourself in state — read the `Date` from `onValueChange`.
  • Don't nest it inside another popover trigger where the overlays would fight for focus.

Accessibility

KeysAction
Enter / SpaceOpen the calendar from the focused trigger.
Arrow keysMove between days once the calendar is open.
EnterSelect the focused day and close the overlay.
EscClose the overlay without changing the value.
  • The overlay is a Radix Popover: it is portalled, dismisses on outside-click and Escape, and returns focus to the trigger on close.
  • Selecting a day closes the overlay and moves focus back to the trigger, so keyboard flow continues in place.
  • `invalid` sets `aria-invalid` on the trigger; the trigger exposes `aria-expanded` for its open state.

DatePicker props

PropTypeDefaultDescription
classNamestring
clearablebooleanfalseShow a clear button when a date is selected.
defaultOpenbooleanInitial open state in uncontrolled mode.
defaultValueDate | nullInitial selected date in uncontrolled mode.
disabledbooleanDisable the whole control.
formatDateTimeFormatOptions | ((date: Date) => string)`{ dateStyle: "medium" }`How the selected date renders in the field. Pass `Intl.DateTimeFormatOptions` or a formatter function.
invalidbooleanMark the field invalid — danger border plus `aria-invalid`.
isDateDisabled((date: Date) => boolean)Predicate to disable arbitrary days.
localestringBCP-47 locale for the field label and the calendar.
maxDateLatest selectable day (inclusive).
minDateEarliest selectable day (inclusive).
onOpenChange((open: boolean) => void)Fires when the overlay opens or closes.
onValueChange((date: Date | null) => void)Fires with the chosen date (or `null` when cleared).
openbooleanControlled open state of the overlay.
placeholderstringSelect dateText shown when no date is selected.
sizeenummdField height: `sm` (32) · `md` (36, default) · `lg` (40).
styleCSSProperties
valueDate | nullControlled selected date. Pass `null` for no selection.
weekStartsOnenum1First column of the week: 0 = Sunday … 6 = Saturday.

Related

  • CalendarMonth-grid date picker with full keyboard navigation, single or range selection, and locale-aware labels.
  • DateInputSegmented day/month/year field with spinbutton segments — the keyboard-first, type-to-fill alternative to the calendar.
  • DateRangePickerSunken field that opens a two-month Calendar for picking a start/end range, with live hover preview and auto-close.
  • FieldForm-field wrapper: a caption label, the control, and hint or error messaging with ARIA wired for you.