Skip to Content
⭐️ Leave a star →
ComponentsDatePicker

Date Picker

A trigger button paired with a popover Calendar. Closes on selection by default. Click-outside and Escape dismiss the popover. Uses the same Calendar primitives under the hood — render any Calendar.* parts inside DatePicker.Calendar.

Features

Composes with the Calendar component.
Closes on selection by default (override with closeOnSelect={false}).
Click-outside and Escape close the popover.
Controlled and uncontrolled date and open state.
Locale-aware formatted display via Intl.DateTimeFormat.
data-state on root, trigger, and content for open/closed styling.

Example

import { Calendar, DatePicker } from '@wire-ui/react' <DatePicker.Root> <DatePicker.Trigger> <DatePicker.Value placeholder="Pick a date" /> </DatePicker.Trigger> <DatePicker.Content> <DatePicker.Calendar> <Calendar.Nav> <Calendar.PrevButton /> <Calendar.Title /> <Calendar.NextButton /> </Calendar.Nav> <Calendar.Grid renderDay={(day) => <button {...day.props}>{day.dayOfMonth}</button>} renderWeekday={(wd) => <div>{wd.short}</div>} /> </DatePicker.Calendar> </DatePicker.Content> </DatePicker.Root>

Styling

The Root and Trigger expose data-state="open" / "closed" so you can ring-focus the trigger when the popover is open. The Content unmounts when closed.

<DatePicker.Trigger className=" data-[state=open]:ring-2 data-[state=open]:ring-black " />

Using data attributes

[data-state="open"] { /* expanded */ } [data-state="closed"] { /* collapsed */ } [data-disabled] { opacity: 0.5; cursor: not-allowed; } [data-placeholder] { color: #a3a3a3; } /* Value with no selection */

Root props

PropTypeDefaultDescription
valueDate | nullControlled date
defaultValueDate | nullnullInitial date
onChange(date: Date | null) => voidCalled when selection changes
openbooleanControlled open state
defaultOpenbooleanfalseInitial open state
onOpenChange(open: boolean) => voidCalled when open state changes
disabledbooleanfalseDisables the trigger
closeOnSelectbooleantrueClose the popover when a date is picked
localestring'en-US'Locale used by the Value formatter
formatOptionsIntl.DateTimeFormatOptions{ year: 'numeric', month: 'short', day: 'numeric' }Format options for the Value display

Value props

PropTypeDescription
placeholderReactNodeRendered when no date is selected
children(date: Date | null, formatted: string) => ReactNodeCustom render function — overrides the default formatted string

Calendar prop

DatePicker.Calendar accepts all Calendar.Root props except value / onChange (which are wired internally). Use it to pass minDate, maxDate, isDateDisabled, weekStartsOn, etc.

Data attributes

AttributeElementValues
data-stateRoot, Trigger"open" / "closed"
data-disabledRootPresent when disabled
data-placeholderValuePresent when no date is selected

Accessibility

  • Trigger sets aria-haspopup="dialog", aria-expanded, and aria-controls.
  • Content has role="dialog" and aria-labelledby pointing to the trigger.
  • Escape closes the popover; click-outside dismisses it.

Keyboard Interactions

KeyDescription
Enter / SpaceOpens the popover when the trigger is focused.
EscapeCloses the popover.
TabMoves focus through the grid; closes on outside focus via click-outside.
Last updated on

MIT License © 2026 wire-ui

Date Picker – Wire UI