Skip to content

Date Picker

A calendar popover that picks a civil date stored as YYYY-MM-DD.

Logs since
hero.tsx

Usage guidelines

  • Use DatePicker for a civil date stored as YYYY-MM-DD, such as a report day or an expiry date. Use TimePicker for a wall time HH:mm and DateTimePicker for an instant (Date) shown in an IANA time zone. The pickers do not accept typed text.
  • A date-only value has no time zone. Parse API payloads and convert business values outside the picker.
  • Name the field at the call site: prefer one visible picker Label. It names both the trigger and the popup through aria-labelledby, and clicking its text focuses the trigger without opening it. A Label with className="sr-only" names a compact field without visible text. FieldLabel nativeLabel={false} render={<div />} also works. Do not point a native label[for] at the trigger: activating it clicks the button.
  • Without a Label, name the trigger and the content with aria-label or aria-labelledby. The trigger's name appends its visible value (or placeholder) to label text; an explicit aria-label replaces the whole name, so include the visible value in it. Put meaningful annotations inside the Value part so they join the name.
  • Name Clear explicitly: Clear follows the IconButton naming contract, so give it an aria-label such as "Clear start date". Place it next to the trigger, never inside the trigger button.
  • Use defaultValue, or value with onValueChange, and keep that choice for the field's lifetime. null means empty, and Clear emits null. details.reason is item-press, clear-press or reset; details.cancel() rejects that change and its follow-up close. Unchanged values do not emit again.
  • Selecting a day commits it and closes the popup. The month and year selector only changes the displayed month; it does not select a date. Days from adjacent months stay selectable.
  • Restrict dates with minDate, maxDate (both YYYY-MM-DD) and isDateUnavailable. Unavailable days are skipped by the keyboard and cannot be selected.
  • Content keeps its natural height and flips above or below the trigger; it does not shrink on small screens. Pass maxHeight only to opt into scrolling the body while the actions stay visible.
  • locale takes a DayPicker locale object and changes formatting and digits, not the calendar system or the stored value. Translate action labels through labels, plus placeholders, requiredLabel and validationMessage. Direction comes from the nearest DirectionProvider; for a local RTL region, also set dir on the wrapper and on the content.
  • With name, the committed value joins native FormData, and an empty field submits ''. Inside a Field, Field.name takes precedence, validate receives the domain value, and Form.onFormSubmit receives the same strings as FormData. Required and invalid fields block submission and focus the first invalid trigger. Reset restores defaultValue. Disabled fields are left out; read-only fields open for browsing and still submit.

Anatomy

tsx
tsx

DatePickerTrigger is a native button whose default children are the Value and a decorative icon. When you replace them, include exactly one DatePickerValue; its render callback receives the formatted text, not the raw value. DatePickerContent owns the portal, initial focus and calendar.

Examples

Available dates

minDate and maxDate bound the calendar, and isDateUnavailable rules out single days such as weekends.

Maintenance date

Weekdays only, Dec 2026–Jan 2027.

constraints.tsx

Controlled value

Control the value with value and onValueChange when another part of the page reads it. The callback's details.reason tells a day selection from Clear or a form reset.

API key expires on

Value: 2027-03-31

controlled.tsx

Read-only and disabled

A read-only picker stays focusable and opens for browsing, but you cannot change its value. A disabled picker leaves the tab order and form submission.

Plan started on

Read-only — opens for browsing, cannot be changed.

Next invoice date

Disabled — skipped by keyboard and form submission.

read-only-disabled.tsx

Field and Form

Inside a Field, the picker registers with Form. FieldError shows the required message, and onFormSubmit receives the serialized date.

Required
Usage report date

Submitted as YYYY-MM-DD, without a time zone.

form.tsx

Keyboard

KeyAction
EnterorSpaceOpens the popup from the trigger and focuses the selected day, or today when empty.
Left arroworRight arrowMoves focus one day, skipping unavailable days and crossing into adjacent months. Reversed in right-to-left.
Up arroworDown arrowMoves focus one week.
PageUporPageDownMoves focus one month.
Shift+PageUporShift+PageDownMoves focus one year.
HomeorEndMoves focus to the start or end of the week.
EnterorSpaceSelects the focused day, closes the popup and returns focus to the trigger.
TabMoves between the month title, the month buttons and the grid, wrapping inside the popup.
EscapeCloses the popup without a change and returns focus to the trigger.

In the month and year selector, ArrowUp and ArrowDown move one option, PageUp and PageDown move five, and Home and End reach the ends. Digits locate a year and letters locate a month. Escape discards the selection and returns focus to the month title.

API reference

DatePicker

Groups all parts of a calendar date picker storing a Gregorian YYYY-MM-DD value. Doesn't render its own HTML element.

Commits changes on day selection, clearing, or form reset; integrates with Field and native form validation.

Base UI Popover.Root docs

Props
PropTypeDefaultDetails
placeholderstringNo default
disabledbooleanfalse
readOnlybooleanfalse
requiredbooleanfalse
requiredLabelstring'Required'
invalidbooleanfalse
namestringNo default
formstringNo default
validationMessagestringNo default
onOpenChange((open: boolean, details: PickerOpenChangeDetails) => void)No default
children requiredReact.ReactNodeNo default
localePartial<DayPickerLocale>No default
minDatestringNo default
maxDatestringNo default
isDateUnavailable((date: string) => boolean)No default
valuestring | nullNo default
defaultValuestring | nullnull
onValueChange((value: string | null, details: DatePickerChangeEventDetails) => void)No default
labelsPartial<DatePickerLabels>No default
Base UI Popover.Root docs

DatePickerClear

A button component that can be used to trigger actions. Renders a <button> element.

Base UI Button docs

Props
PropTypeDefaultDetails
aria-labelstringNo default
aria-labelledbystringNo default
variant'default' | 'ghost' | 'ghost-accent' | 'primary' | 'secondary' | 'secondary-accent' | 'tertiary''default'
tone'default' | 'destructive''default'
refReact.Ref<HTMLButtonElement>No default
Base UI Button docs

Valid prop combinations:

  • aria-label: string, aria-labelledby?: undefined, variant?: 'default' | 'ghost' | 'primary' | 'secondary' | 'tertiary', tone?: 'default' | 'destructive'
  • aria-label: string, aria-labelledby?: undefined, variant: 'ghost-accent' | 'secondary-accent', tone?: 'default'
  • aria-label?: undefined, aria-labelledby: string, variant?: 'default' | 'ghost' | 'primary' | 'secondary' | 'tertiary', tone?: 'default' | 'destructive'
  • aria-label?: undefined, aria-labelledby: string, variant: 'ghost-accent' | 'secondary-accent', tone?: 'default'
Data attributes
AttributeDescription
data-disabled

Present when the button is disabled.

DatePickerContent

A container for the popover contents. Renders a <div> element.

Base UI Popover.Popup docs

Props
PropTypeDefaultDetails
sideOffsetnumber | OffsetFunction8
align'center' | 'end' | 'start''start'
Base UI Popover.Popup docs
Data attributes
AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-starting-style

Present when the popup begins animating in.

data-ending-style

Present when the popup is animating out.

data-side

Values: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

Indicates how the popup is aligned relative to specified side.

data-instant

Values: 'click' | 'dismiss' | 'focus' | 'trigger-change'

Present if animations should be instant.

CSS variables
VariableDescription
--popup-width

The width of the popup.

--popup-height

The height of the popup.

DatePickerLabel

Data attributes
AttributeDescription
data-disabled

Present when the component should ignore user interaction.

data-touched

Present when the field has been touched.

data-dirty

Present when the field value has changed from its initial value.

data-filled

Present when the field has a value.

data-focused

Present when the field is focused.

DatePickerTrigger

A button that opens the popover. Renders a <button> element.

Base UI Popover.Trigger docs

Props
PropTypeDefaultDetails
refReact.Ref<HTMLButtonElement>No default
Base UI Popover.Trigger docs
Data attributes
AttributeDescription
data-readonly

Present when the picker is read-only.

data-required

Present when the picker requires a value.

data-popup-open

Present when the corresponding popover is open.

data-pressed

Present when the trigger is pressed.

data-disabled

Present when the trigger is disabled.

DatePickerValue

Props
PropTypeDefaultDetails
children((displayValue: string) => React.ReactNode) | React.ReactNodeNo default