Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Date Picker

PreviousNext

A date field that opens a calendar, with an optional time wheel, a month or year granularity, and Calendar compositions for ranges and presets.

The day the work begins.

Click the field and pick a day from the calendar. With hasTime, a time wheel sits beside the calendar, as in the iOS Clock app: the field reads Nov 12, 2026, 10:30 AM, and the value is that day at that time. With granularity="month" or "year", a grid of twelve months or years takes the calendar's place. For people who'd rather type, editable adds a text field that reads 2026-11-12, Nov 12, 2026 or tomorrow at 9pm.

The DatePicker field is part of the Fabricator style. It's composed from Popover, Calendar and the Time Input wheel, with Fluid Hover on the month and year grid, and framed like every other field, so the focus ring and invalid state match. With editable, the field is an Input Group.

Installation

bunx --bun fabricator-ui@latest add date-picker

Usage

import { DatePicker } from "@/components/ui/date-picker"
<DatePicker aria-label="Due date" />
<DatePicker aria-label="Starts" hasTime />
<DatePicker aria-label="Billing month" granularity="month" />

Composition

DatePicker
├── PopoverTrigger               the field: the date, or its placeholder
├── PopoverContent
│   ├── Calendar                 one month, single selection
│   ├── TimeWheel                with `hasTime`: hours, minutes, seconds, AM or PM
│   └── grid                     instead of both, at a month or year granularity:
│                                twelve cells, three to a row, under the page's arrows
└── input[type=hidden]           with `name`: yyyy-MM-dd, yyyy-MM-ddTHH:mm(:ss), yyyy-MM or yyyy

With editable, the field is an InputGroup instead: an InputGroupInput for the text and an InputGroupButton that opens the same popover.

className goes on the root, for layout. id, placeholder, disabled and the aria-* labels go to the field; with editable, every other input prop goes to the text input as well.

Examples

Field

Put it in a Field with a FieldLabel pointing at its id, and a FieldDescription for what to pick.

The day the work begins.

Date and time

hasTime puts a Time Input wheel beside the calendar, as tall as it: hours, minutes, AM or PM on a 12-hour clock, and seconds with hasSeconds. It opens on the value's time, or now. Pick a day and turn the wheel: the field shows both and the value follows as each column settles. A new day keeps the time. Enter, Escape or a click elsewhere closes the popover. step sets the minutes between the minute wheel's rows (1 by default), and the clock follows the reader's locale unless hourCycle fixes one.

Month and year

granularity="month" picks a month from a year of them; granularity="year" picks a year from a page of twelve. The arrows beside the heading turn the page, one highlight glides between the cells, and a new page slides in from the side it came from. The value is still a Date: the first day of the month or year. The text reads Mar 2028 or 2028; format changes it. minDate and maxDate compare whole months or years, and hasTime doesn't apply.

With editable, a month reads Mar 2028, March 2028, 2028-03, 3/2028 and this month, next month or last month; a year reads 2028 and this year, next year or last year. Use a month for a card's expiry or a billing period, where the browser would offer <input type="month">.

Type 3/2028 or Mar 2028, or pick it from the year.

From 1980 to 2030.

Typing

editable makes the field a text input with a calendar button, for people who know the date already. The text is read on Enter or when the field loses focus, then rewritten in the display format. With hasTime, the time comes after a comma or "at": Nov 12, 2026, 10:30 AM or tomorrow at 9pm. See What it reads.

Controlled

Control the value with value and onValueChange. It changes when a day (and, with hasTime, a time) is picked, or when typed text is committed, not on every keystroke.

Thursday, November 12, 2026

Format

format is a date-fns pattern for the text, MMM d, yyyy by default. With editable, typing reads the same pattern, and ISO yyyy-MM-dd always works. Pass a date-fns locale to write and read month names in another language; it also sets the calendar's.

Day, month, then year.

Minimum and maximum

minDate and maxDate turn off the days outside them in the calendar, and stop its navigation at their months. With editable, a typed date outside them is rewritten, marked invalid, and leaves the value empty.

Between Nov 9 and Dec 18, 2026.

Invalid

Pass aria-invalid to show your own validation, with the message in a FieldError. With editable, text that isn't a date sets it on its own.

Disabled

Sizes

The field follows the nearest density. Add density-compact or density-spacious to one field, or wrap a form in a DensityProvider.

In a form

With name, a hidden input sends the day as yyyy-MM-dd, or yyyy-MM-ddTHH:mm with hasTime (yyyy-MM-ddTHH:mm:ss with hasSeconds), whatever the display format. A month sends yyyy-MM, what <input type="month"> submits, and a year yyyy. With editable, Enter commits the text first; a second Enter submits.

The form sends yyyy-MM-dd.

Compositions

DatePicker is one date, with or without a time. For a range, presets, or a range with times, compose a Calendar in a Popover yourself. There is no root component for these; each example is the whole recipe.

Popover
├── PopoverTrigger
└── PopoverContent
    └── Calendar

For times on a range, put a TimeRangeInput from Time Input under the trigger: a start and an end with the duration between them. See Date and Time Range.

See the React DayPicker documentation for more information.

Basic

A basic date picker component.

Range Picker

A date picker component for selecting a range of dates.

Date of Birth

A date picker component for selecting a date of birth. This component includes a dropdown caption layout for date and month selection.

Date and Time Range

The days from a range calendar, and a start and an end time below them. On a single day the times are a TimeRangeInput: the end's list counts the duration from the start, moving the start keeps it, and an end at or before the start is marked invalid. Across days, any two times work.

Natural Language Picker

This component uses the chrono-node library to parse natural language dates.

Your post will be published on November 20, 2026.

What it reads

With editable, the text field reads:

TypedBecomes
The display format (Nov 12, 2026)That day
ISO (2026-11-12)That day
today, tomorrow, yesterdayThat day, from the person's clock
With hasTime, a time after a comma or at (Nov 12, 2026, 10:30 AM, tomorrow at 9pm)That day at that time
A month: Mar 2028, March 2028, 2028-03, 3/2028, this month, next month, last monthThe first of that month
A year: 2028, this year, next year, last yearThe first of that year
NothingNo value
Anything else, or a day that can't beNo value; the text stays and is invalid

Case and extra spaces don't matter. Years need four digits, so Nov 12, 26 isn't read as the year 26. The rules are pure functions in lib/date-picker-model.ts (parseDateText, commitDateText, formatDateValue, formatIsoDate, formatIsoDateTime, setDateTime, splitDateTimeText, isDateInRange, and getDateGridOptions for the grid), each taking a granularity, which you can use for your own validation.

API Reference

DatePicker

PropTypeDefault
valueDate | undefined-
defaultValueDate-
onValueChange(value: Date | undefined) => void-
granularity"day" | "month" | "year""day"
formatstring (date-fns pattern)"MMM d, yyyy", "MMM yyyy" or "yyyy"
localeLocale (date-fns)-
minDateDate-
maxDateDate-
namestring-
hasTimeboolean (days only)false
stepnumber (minutes)1
hasSecondsbooleanfalse
hourCycle12 | 24the locale's
editablebooleanfalse
calendarLabelstring"Choose date", "Choose month" or "Choose year"
timeLabelstring"Choose time"
placeholderstring"Pick a date", "Pick a date and time", "Pick a month" or "Pick a year"
disabledbooleanfalse
aria-invalidboolean-

Data attributes

AttributeElementPresent when
data-slot="date-picker"rootalways
data-slot="date-picker-field"the field (a button)not editable
data-slot="input-group-control"the text inputeditable
data-slot="date-picker-time"the wheel's columnopen, hasTime
data-slot="date-picker-grid"the month or year gridopen, a month or year granularity
data-slot="date-picker-cell"each month or yearopen, a month or year granularity
data-currentthis month or yearopen, a month or year granularity
data-slot="popover-content"the calendar's popupopen
data-slot="date-picker-value"the hidden inputname is set

Accessibility

  • The field is a button that reports aria-expanded. Label it with a FieldLabel pointing at its id, or aria-label; the placeholder isn't a label.
  • Enter, Space or a click opens the calendar on the selected day's month, with focus on that day. Arrow keys move by day and week, Page Up and Page Down by month, Enter or Space picks, and Escape closes.
  • With hasTime, Tab moves from the calendar to the wheel, a group named by timeLabel. Each column is a spinbutton (Hours, Minutes, Seconds, AM or PM): Arrow Up and Down step it, Page Up and Page Down jump five, Home and End go to the ends, and Tab moves to the next column. Enter closes the popover.
  • At a month or year granularity, the cells are a grid with focus on the selected cell, or this month or year. Left and Right move by one, Up and Down by three, Page Up and Page Down by a page of twelve, Enter or Space picks, and Escape closes. The heading is announced as it changes.
  • Without hasTime, picking a day, month or year closes the popover. Closing returns focus to the field.
  • With editable, the text input is a plain text field and Alt+ArrowDown opens the calendar (announced through aria-keyshortcuts); its button is named by calendarLabel. Text that isn't a date sets aria-invalid.
  • aria-invalid turns the frame red, and screen readers announce it.
  • Disabled, the field leaves the tab order and the hidden input isn't submitted.