Date Picker
A component that allows users to select a date from a calendar.
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, omitPortal,Positioner, andContent.
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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. | |
closeOnSelect | true | booleanWhether the calendar should close after the date selection is complete. This is ignored when the selection mode is `multiple`. |
createCalendar | (identifier: CalendarIdentifier) => CalendarA 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 | DateValueThe initial focused date when rendered. Use when you don't need to control the focused date of the date picker. | |
defaultOpen | booleanThe 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' | DateViewThe default view of the calendar |
disabled | booleanWhether the calendar is disabled. | |
fixedWeeks | booleanWhether the calendar should have a fixed number of weeks. This renders the calendar with 6 weeks instead of 5 or 6. | |
focusedValue | DateValueThe controlled focused date. | |
format | (date: DateValue, details: LocaleDetails) => stringThe format of the date to display in the input. | |
hideMode | 'display-none' | HideModeHow 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 | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the date picker. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
inline | booleanWhether to render the date picker inline | |
invalid | booleanWhether the date picker is invalid | |
isDateUnavailable | (date: DateValue, locale: string) => booleanReturns whether a date of the calendar is available. | |
lazyMount | false | booleanWhether to enable lazy mounting |
locale | 'en-US' | stringThe locale (BCP 47 language tag) to use when formatting the date. |
max | DateValueThe maximum date that can be selected. | |
maxSelectedDates | numberThe maximum number of dates that can be selected. This is only applicable when `selectionMode` is `multiple`. | |
maxView | 'year' | DateViewThe maximum view of the calendar |
min | DateValueThe minimum date that can be selected. | |
minView | 'day' | DateViewThe minimum view of the calendar |
name | stringThe `name` attribute of the input element. | |
numOfMonths | numberThe number of months to display. | |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onFocusChange | (details: FocusChangeDetails) => voidFunction called when the focused date changes. | |
onOpenChange | (details: OpenChangeDetails) => voidFunction called when the calendar opens or closes. | |
onValueChange | (details: ValueChangeDetails) => voidFunction called when the value changes. | |
onViewChange | (details: ViewChangeDetails) => voidFunction called when the view changes. | |
onVisibleRangeChange | (details: VisibleRangeChangeDetails) => voidFunction called when the visible range changes. | |
open | booleanThe controlled open state of the date picker | |
openOnClick | false | booleanWhether to open the calendar when the input is clicked. |
outsideDaySelectable | false | booleanWhether day outside the visible range can be selected. |
parse | (value: string, details: LocaleDetails) => DateValue | undefinedFunction to parse the date from the input back to a DateValue. | |
placeholder | stringThe placeholder text to display in the input. | |
positioning | PositioningOptionsThe user provided options used to position the date picker content | |
present | booleanWhether the node is present (controlled by the user) | |
readOnly | booleanWhether 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 | booleanWhether the date picker is required | |
selectionMode | 'single' | SelectionModeThe 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 | booleanWhether to show the week number column in the day view. | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
startOfWeek | numberThe first day of the week. `0` - Sunday `1` - Monday `2` - Tuesday `3` - Wednesday `4` - Thursday `5` - Friday `6` - Saturday | |
timeZone | 'UTC' | stringThe time zone to use |
translations | IntlTranslationsThe localized messages to use. | |
unmountOnExit | false | booleanWhether to unmount on exit. |
value | DateValue[]The controlled selected date(s). | |
view | DateViewThe view of the calendar |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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 Variable | Description |
|---|---|
--layer-index | The index of the dismissable in the layer stack |
--nested-layer-count | The number of nested date-pickers |
Control
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. | |
fixOnBlur | true | booleanWhether to fix the input value on blur. |
index | numberThe 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-next-trigger] | <uid> |
[data-disabled] | Present when disabled |
Positioner
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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 Variable | Description |
|---|---|
--reference-width | The width of the reference element |
--reference-height | The height of the root |
--available-width | The available width in viewport |
--available-height | The available height in viewport |
--x | The x position for transform |
--y | The y position for transform |
--transform-origin | The transform origin for animations |
PresetTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
value | PresetTriggerValue | |
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
value | UseDatePickerReturn | |
asChild | booleanUse 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' | HideModeHow 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 | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
present | booleanWhether 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. | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
TableBody
Defines the <tbody> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-table-body] | <uid> |
[data-view] | The view of the tablebody |
[data-disabled] | Present when disabled |
TableCell
Defines the <td> element.
| Attribute | Default | Type |
|---|---|---|
value | number | DateValue | |
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-table-head] | <uid> |
[data-view] | The view of the tablehead |
[data-disabled] | Present when disabled |
TableHeader
Defines the <th> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-table-header] | <uid> |
[data-view] | The view of the tableheader |
[data-disabled] | Present when disabled |
Table
Defines the <table> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-table] | <uid> |
[data-columns] | |
[data-view] | The view of the table |
TableRow
Defines the <tr> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-table-row] | <uid> |
[data-disabled] | Present when disabled |
[data-view] | The view of the tablerow |
Trigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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 | stringText 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 | ', ' | stringThe separator to use between multiple date values when using default rendering. |
ValueTextRender
| Prop | Default | Type |
|---|---|---|
index | number | |
remove | () => void | |
value | DateValue | |
valueAsString | string |
ViewControl
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-view-control] | <uid> |
[data-view] | The view of the viewcontrol |
View
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
view | DateView | |
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-view] | <uid> |
[data-view] | The view of the view |
ViewTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-date-picker-view-trigger] | <uid> |
[data-view] | The view of the viewtrigger |
[data-disabled] | Present when disabled |
WeekNumberCell
Defines the <td> element.
| Attribute | Default | Type |
|---|---|---|
week | DateValue[] | |
weekIndex | number | |
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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
| Property | Type |
|---|---|
focused | booleanWhether the input is focused |
open | booleanWhether the date picker is open |
disabled | booleanWhether the date picker is disabled |
invalid | booleanWhether the date picker is invalid |
readOnly | booleanWhether the date picker is read-only |
inline | booleanWhether the date picker is rendered inline |
numOfMonths | numberThe number of months to display |
showWeekNumbers | booleanWhether the week number column is shown in the day view |
selectionMode | SelectionModeThe selection mode (single, multiple, or range) |
maxSelectedDates | number | undefinedThe maximum number of dates that can be selected (only for multiple selection mode). |
isMaxSelected | booleanWhether the maximum number of selected dates has been reached. |
view | DateViewThe current view of the date picker |
getWeekNumber | (week: DateValue[]) => numberReturns 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) => DateValueOffsetReturns 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) => booleanReturns 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 | VisibleRangeThe visible range of dates. |
visibleRangeText | VisibleRangeTextThe 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 | DateValueThe focused date. |
focusedValueAsDate | DateThe focused date as a Date object. |
focusedValueAsString | stringThe focused date as a string. |
selectToday | VoidFunctionSets the selected date to today. |
setValue | (values: DateValue[]) => voidSets the selected date to the given date. |
setTime | (time: Time, index?: number) => voidSets the time for a specific date value. Converts CalendarDate to CalendarDateTime if needed. |
setFocusedValue | (value: DateValue) => voidSets the focused date to the given date. |
clearValue | (options?: { focus?: boolean }) => voidClears the selected date(s). |
setOpen | (open: boolean, reason?: OpenChangeReason) => voidFunction to open or close the calendar. |
focusMonth | (month: number) => voidFunction to set the selected month. |
focusYear | (year: number) => voidFunction to set the selected year. |
getYears | () => Cell[]Returns the months of the year |
getYearsGrid | (props?: YearGridProps) => YearGridValueReturns 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) => MonthGridValueReturns the months of the year based on the columns. Represented as an array of arrays of months. |
format | (value: DateValue, opts?: Intl.DateTimeFormatOptions) => stringFormats the given date value based on the provided options. |
setView | (view: DateView) => voidSets the view of the date picker. |
goToNext | VoidFunctionGoes to the next month/year/decade. |
goToPrevious | VoidFunctionGoes to the previous month/year/decade. |
getDayTableCellState | (props: DayTableCellProps) => DayTableCellStateReturns the state details for a given cell. |
getMonthTableCellState | (props: TableCellProps) => TableCellStateReturns the state details for a given month cell. |
getYearTableCellState | (props: TableCellProps) => TableCellStateReturns the state details for a given year cell. |
getRootState | () => RootStateReturns the state of the root. |
getContentState | () => ContentStateReturns the state of the content. |
getTriggerState | () => TriggerStateReturns the state of the trigger. |
getInputState | (props?: InputProps) => InputStateReturns the state of the input. |
Accessibility
Keyboard Support
| Key | Description |
|---|---|
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. |