Date Picker

A component that allows users to select a date from a calendar.

Loading...

Anatomy

<DatePicker.Root>
  <DatePicker.Label />
  <DatePicker.Control>
    <DatePicker.Input />
    <DatePicker.Trigger />
    <DatePicker.ClearTrigger />
  </DatePicker.Control>
  <DatePicker.Positioner>
    <DatePicker.Content>
      <DatePicker.View>
        <DatePicker.ViewControl>
          <DatePicker.PrevTrigger />
          <DatePicker.ViewTrigger>
            <DatePicker.RangeText />
          </DatePicker.ViewTrigger>
          <DatePicker.NextTrigger />
        </DatePicker.ViewControl>
        <DatePicker.Table>
          <DatePicker.TableHead>
            <DatePicker.TableRow>
              <DatePicker.TableHeader />
            </DatePicker.TableRow>
          </DatePicker.TableHead>
          <DatePicker.TableBody>
            <DatePicker.TableRow>
              <DatePicker.TableCell>
                <DatePicker.TableCellTrigger />
              </DatePicker.TableCell>
            </DatePicker.TableRow>
          </DatePicker.TableBody>
        </DatePicker.Table>
      </DatePicker.View>
    </DatePicker.Content>
  </DatePicker.Positioner>
</DatePicker.Root>

Examples

Default Value

Use defaultValue with parseDate to set the initial date.

Controlled

Use value and onValueChange to control the value.

Root Provider

Use RootProvider with the useDatePicker hook to access the state and methods from outside the component.

Default View

Set defaultView to open the calendar on the day, month, or year view.

Month and Year Select

Use MonthSelect and YearSelect next to the prev/next triggers for dropdown month and year navigation.

Range

Set selectionMode="range" and render two inputs with index set to 0 and 1.

Multiple

Set selectionMode="multiple" to select several dates. This example shows them as removable tags.

Max Selected Dates

Use maxSelectedDates with selectionMode="multiple" to cap the selection. Here the limit is 3.

Multiple Months

Set numOfMonths to show months side by side. Use datePicker.getOffset({ months: 1 }) to get the next month's data.

Presets

Use DatePicker.PresetTrigger for presets like "Last 7 days" or "This month".

Min and Max

Use min and max with parseDate to restrict the range. Dates outside it are disabled.

Unavailable

Use isDateUnavailable to mark dates as unavailable. This example disables weekends.

Locale

Set locale for language and formatting. Set startOfWeek for the first day of the week (0 = Sunday, 1 = Monday).

Month Picker

Set defaultView="month" and minView="month". Custom format and parse functions handle the month/year input.

Year Picker

Set defaultView="year" and minView="year". Custom format and parse functions handle the year input.

Inline

Set inline to render the calendar on the page without a popup.

With inline, omit Portal, Positioner, and Content.

Custom Parsing

Use parse for custom parsing, so users can type formats like "25/12" or "25/12/24".

Month Picker Range

Combine selectionMode="range" with defaultView="month" and minView="month", for example for billing periods.

Year Range

Combine selectionMode="range" with defaultView="year" and minView="year" to select multi-year periods.

Select Today

Call selectToday from the context to build a "Today" button.

Fixed Weeks

Set fixedWeeks to always show 6 weeks, so the layout doesn't shift between months.

Form

Set name to submit the selected date with a native form. This example also disables weekends with isDateUnavailable.

With Time

Use CalendarDateTime from @internationalized/date to add a time input. It updates the hour and minute of the selected value.

API Reference

Props

Root

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
closeOnSelecttrue
boolean

Whether the calendar should close after the date selection is complete. This is ignored when the selection mode is `multiple`.

createCalendar
(identifier: CalendarIdentifier) => Calendar

A function that creates a Calendar object for a given calendar identifier. Enables non-Gregorian calendar support (Persian, Buddhist, Islamic, etc.) without bundling all calendars by default.

defaultFocusedValue
DateValue

The initial focused date when rendered. Use when you don't need to control the focused date of the date picker.

defaultOpen
boolean

The initial open state of the date picker when rendered. Use when you don't need to control the open state of the date picker.

defaultValue
DateValue[]

The initial selected date(s) when rendered. Use when you don't need to control the selected date(s) of the date picker.

defaultView'day'
DateView

The default view of the calendar

disabled
boolean

Whether the calendar is disabled.

fixedWeeks
boolean

Whether the calendar should have a fixed number of weeks. This renders the calendar with 6 weeks instead of 5 or 6.

focusedValue
DateValue

The controlled focused date.

format
(date: DateValue, details: LocaleDetails) => string

The format of the date to display in the input.

hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

id
string

The unique identifier of the machine.

ids
ElementIds

The ids of the elements in the date picker. Useful for composition.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

inline
boolean

Whether to render the date picker inline

invalid
boolean

Whether the date picker is invalid

isDateUnavailable
(date: DateValue, locale: string) => boolean

Returns whether a date of the calendar is available.

lazyMountfalse
boolean

Whether to enable lazy mounting

locale'en-US'
string

The locale (BCP 47 language tag) to use when formatting the date.

max
DateValue

The maximum date that can be selected.

maxSelectedDates
number

The maximum number of dates that can be selected. This is only applicable when `selectionMode` is `multiple`.

maxView'year'
DateView

The maximum view of the calendar

min
DateValue

The minimum date that can be selected.

minView'day'
DateView

The minimum view of the calendar

name
string

The `name` attribute of the input element.

numOfMonths
number

The number of months to display.

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

onFocusChange
(details: FocusChangeDetails) => void

Function called when the focused date changes.

onOpenChange
(details: OpenChangeDetails) => void

Function called when the calendar opens or closes.

onValueChange
(details: ValueChangeDetails) => void

Function called when the value changes.

onViewChange
(details: ViewChangeDetails) => void

Function called when the view changes.

onVisibleRangeChange
(details: VisibleRangeChangeDetails) => void

Function called when the visible range changes.

open
boolean

The controlled open state of the date picker

openOnClickfalse
boolean

Whether to open the calendar when the input is clicked.

outsideDaySelectablefalse
boolean

Whether day outside the visible range can be selected.

parse
(value: string, details: LocaleDetails) => DateValue | undefined

Function to parse the date from the input back to a DateValue.

placeholder
string

The placeholder text to display in the input.

positioning
PositioningOptions

The user provided options used to position the date picker content

present
boolean

Whether the node is present (controlled by the user)

readOnly
boolean

Whether the calendar is read-only.

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DatePickerRootState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

required
boolean

Whether the date picker is required

selectionMode'single'
SelectionMode

The selection mode of the calendar. - `single` - only one date can be selected - `multiple` - multiple dates can be selected - `range` - a range of dates can be selected

showWeekNumbers
boolean

Whether to show the week number column in the day view.

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

startOfWeek
number

The first day of the week. `0` - Sunday `1` - Monday `2` - Tuesday `3` - Wednesday `4` - Thursday `5` - Friday `6` - Saturday

timeZone'UTC'
string

The time zone to use

translations
IntlTranslations

The localized messages to use.

unmountOnExitfalse
boolean

Whether to unmount on exit.

value
DateValue[]

The controlled selected date(s).

view
DateView

The view of the calendar

AttributeDescription
[data-date-picker-root]<uid>
[data-state]"open" | "closed"
[data-disabled]Present when disabled
[data-readonly]Present when read-only
[data-invalid]Present when invalid
[data-empty]Present when the content is empty

ClearTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Content

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DatePickerContentState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-content]<uid>
[data-state]"open" | "closed"
[data-placement]The placement of the content
[data-side]The side of the trigger that the content is positioned on
[data-inline]Present when the content is inline
[data-nested]popover
[data-has-nested]popover
CSS VariableDescription
--layer-indexThe index of the dismissable in the layer stack
--nested-layer-countThe number of nested date-pickers

Control

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-control]<uid>
[data-disabled]Present when disabled
[data-placeholder-shown]Present when placeholder is shown
[data-invalid]Present when invalid

Input

Defines the <input> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
fixOnBlurtrue
boolean

Whether to fix the input value on blur.

index
number

The index of the input to focus.

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DatePickerInputState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-input]<uid>
[data-index]The index of the item
[data-state]"open" | "closed"
[data-placeholder-shown]Present when placeholder is shown
[data-invalid]Present when invalid

Label

Defines the <label> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-label]<uid>
[data-state]"open" | "closed"
[data-index]The index of the item
[data-disabled]Present when disabled
[data-readonly]Present when read-only
[data-invalid]Present when invalid

MonthSelect

Defines the <select> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

NextTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-next-trigger]<uid>
[data-disabled]Present when disabled

Positioner

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-positioner]<uid>
[data-nested]Present when the positioner is nested within another {{widget}}
[data-has-nested]Present when the positioner has nested {{widget}}s
CSS VariableDescription
--reference-widthThe width of the reference element
--reference-heightThe height of the root
--available-widthThe available width in viewport
--available-heightThe available height in viewport
--xThe x position for transform
--yThe y position for transform
--transform-originThe transform origin for animations

PresetTrigger

Defines the <button> element.

AttributeDefaultType
value
PresetTriggerValue

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

PrevTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

RangeText

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

RootProvider

Defines the <div> element.

AttributeDefaultType
value
UseDatePickerReturn

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

lazyMountfalse
boolean

Whether to enable lazy mounting

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

present
boolean

Whether the node is present (controlled by the user)

render
type ONLY_FOR_FORMAT = ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DatePickerRootProviderState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

unmountOnExitfalse
boolean

Whether to unmount on exit.

TableBody

Defines the <tbody> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table-body]<uid>
[data-view]The view of the tablebody
[data-disabled]Present when disabled

TableCell

Defines the <td> element.

AttributeDefaultType
value
number | DateValue

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
columns
number

disabled
boolean

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

visibleRange
VisibleRange

TableCellTrigger

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

TableHead

Defines the <thead> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table-head]<uid>
[data-view]The view of the tablehead
[data-disabled]Present when disabled

TableHeader

Defines the <th> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table-header]<uid>
[data-view]The view of the tableheader
[data-disabled]Present when disabled

Table

Defines the <table> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
columns
number

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table]<uid>
[data-columns]
[data-view]The view of the table

TableRow

Defines the <tr> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table-row]<uid>
[data-disabled]Present when disabled
[data-view]The view of the tablerow

Trigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DatePickerTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-trigger]<uid>
[data-placement]The placement of the trigger
[data-side]The side of the trigger that the trigger is positioned on
[data-state]"open" | "closed"
[data-placeholder-shown]Present when placeholder is shown

ValueText

Defines the <span> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
placeholder
string

Text to display when no date is selected.

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

separator', '
string

The separator to use between multiple date values when using default rendering.

ValueTextRender

PropDefaultType
index
number

remove
() => void

value
DateValue

valueAsString
string

ViewControl

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-view-control]<uid>
[data-view]The view of the viewcontrol

View

Defines the <div> element.

AttributeDefaultType
view
DateView

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-view]<uid>
[data-view]The view of the view

ViewTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-view-trigger]<uid>
[data-view]The view of the viewtrigger
[data-disabled]Present when disabled

WeekNumberCell

Defines the <td> element.

AttributeDefaultType
week
DateValue[]

weekIndex
number

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table-cell]<uid>
[data-view]The view of the weeknumbercell
[data-week-index]
[data-type]"week-number"
[data-disabled]Present when disabled

WeekNumberHeaderCell

Defines the <th> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-date-picker-table-cell]<uid>
[data-view]The view of the weeknumberheadercell
[data-type]"week-number"
[data-disabled]Present when disabled

YearSelect

Defines the <select> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Context

API

PropertyType
focused
boolean

Whether the input is focused

open
boolean

Whether the date picker is open

disabled
boolean

Whether the date picker is disabled

invalid
boolean

Whether the date picker is invalid

readOnly
boolean

Whether the date picker is read-only

inline
boolean

Whether the date picker is rendered inline

numOfMonths
number

The number of months to display

showWeekNumbers
boolean

Whether the week number column is shown in the day view

selectionMode
SelectionMode

The selection mode (single, multiple, or range)

maxSelectedDates
number | undefined

The maximum number of dates that can be selected (only for multiple selection mode).

isMaxSelected
boolean

Whether the maximum number of selected dates has been reached.

view
DateView

The current view of the date picker

getWeekNumber
(week: DateValue[]) => number

Returns the ISO 8601 week number (1-53) for the given week (array of dates).

getDaysInWeek
(week: number, from?: DateValue) => DateValue[]

Returns an array of days in the week index counted from the provided start date, or the first visible date if not given.

getOffset
(duration: DateDuration) => DateValueOffset

Returns the offset of the month based on the provided number of months.

getRangePresetValue
(value: DateRangePreset) => DateValue[]

Returns the range of dates based on the provided date range preset.

getMonthWeeks
(from?: DateValue) => DateValue[][]

Returns the weeks of the month from the provided date. Represented as an array of arrays of dates.

isUnavailable
(date: DateValue) => boolean

Returns whether the provided date is available (or can be selected)

weeks
DateValue[][]

The weeks of the month. Represented as an array of arrays of dates.

weekDays
WeekDay[]

The days of the week. Represented as an array of strings.

visibleRange
VisibleRange

The visible range of dates.

visibleRangeText
VisibleRangeText

The human readable text for the visible range of dates.

value
DateValue[]

The selected date.

valueAsDate
Date[]

The selected date as a Date object.

valueAsString
string[]

The selected date as a string.

focusedValue
DateValue

The focused date.

focusedValueAsDate
Date

The focused date as a Date object.

focusedValueAsString
string

The focused date as a string.

selectToday
VoidFunction

Sets the selected date to today.

setValue
(values: DateValue[]) => void

Sets the selected date to the given date.

setTime
(time: Time, index?: number) => void

Sets the time for a specific date value. Converts CalendarDate to CalendarDateTime if needed.

setFocusedValue
(value: DateValue) => void

Sets the focused date to the given date.

clearValue
(options?: { focus?: boolean }) => void

Clears the selected date(s).

setOpen
(open: boolean, reason?: OpenChangeReason) => void

Function to open or close the calendar.

focusMonth
(month: number) => void

Function to set the selected month.

focusYear
(year: number) => void

Function to set the selected year.

getYears
() => Cell[]

Returns the months of the year

getYearsGrid
(props?: YearGridProps) => YearGridValue

Returns the years of the decade based on the columns. Represented as an array of arrays of years.

getDecade
() => Range<number | undefined>

Returns the start and end years of the decade.

getMonths
(props?: MonthFormatOptions) => Cell[]

Returns the months of the year

getMonthsGrid
(props?: MonthGridProps) => MonthGridValue

Returns the months of the year based on the columns. Represented as an array of arrays of months.

format
(value: DateValue, opts?: Intl.DateTimeFormatOptions) => string

Formats the given date value based on the provided options.

setView
(view: DateView) => void

Sets the view of the date picker.

goToNext
VoidFunction

Goes to the next month/year/decade.

goToPrevious
VoidFunction

Goes to the previous month/year/decade.

getDayTableCellState
(props: DayTableCellProps) => DayTableCellState

Returns the state details for a given cell.

getMonthTableCellState
(props: TableCellProps) => TableCellState

Returns the state details for a given month cell.

getYearTableCellState
(props: TableCellProps) => TableCellState

Returns the state details for a given year cell.

getRootState
() => RootState

Returns the state of the root.

getContentState
() => ContentState

Returns the state of the content.

getTriggerState
() => TriggerState

Returns the state of the trigger.

getInputState
(props?: InputProps) => InputState

Returns the state of the input.

Accessibility

Keyboard Support

KeyDescription
ArrowLeft
Moves focus to the previous day within the current week.
ArrowRight
Moves focus to the next day within the current week.
ArrowUp
Moves focus to the same day of the week in the previous week.
ArrowDown
Moves focus to the same day of the week in the next week.
Home
Moves focus to the first day of the current month.
End
Moves focus to the last day of the current month.
PageUp
Moves focus to the same day of the month in the previous month.
PageDown
Moves focus to the same day of the month in the next month.
Enter
Selects the focused date and closes the date picker.
Esc
Closes the date picker without selecting any date.