Date Picker

A field that opens a calendar to pick a date or a range of dates.

Installation

  1. Add the registryOnce per project
  2. Add date-picker

Usage

DatePickerTrigger shows the date, or its placeholder while there's none. Give it children to format the date yourself. DatePickerContent opens a Calendar and takes its props.

Composition

Examples

With a label

Point a FieldLabel at the trigger's id. Without a visible label, give the trigger an aria-label.

The release goes out at 9:00 that morning.

Range

With mode="range", the value is a { from, to } range. numberOfMonths={2} on the content shows two months at once.

Month and year dropdowns

For dates far from now, such as a birthday, captionLayout="dropdown" adds month and year menus. Bound them with startMonth and endMonth.

Disabled days

Pass disabled matchers to the content to rule out days.

We deliver on weekdays.

In a form

Give a Field or the picker a name, and the value submits under it: a date as YYYY-MM-DD, and a range as YYYY-MM-DD/YYYY-MM-DD, an ISO 8601 interval. Pass form with a form's id when the picker sits outside it. With required, the form won't submit without a date, or a range with both its ends, which fails as valueMissing. A form reset brings back defaultValue.

Check in and check out.

Sizes

size on the trigger matches the sizes of buttons, inputs and selects.

Invalid

Set invalid on the Field, and explain the problem with a FieldError. The trigger reads out the field's FieldDescription and FieldError, and turns invalid or disabled with the field.

Props

DatePickerContent takes DayPicker's props other than the selection ones, plus side, sideOffset, align and alignOffset.

The tables leave out className, style and render. Parts built on Base UI take them as its styling and composition guides describe.

DatePicker

DatePickerTrigger

DatePickerContent