Components
Date picker

Date Picker

The Date Picker is a comprehensive tool for date selection within your application. It supports various view modes (day, month, year), single date selection, and range selection. This component also allows the rendering of multiple grids for a broader date range view.

API reference docs for the component. Learn about the props, CSS, and other APIs of this exported module.

DatePickerProps

dir

'ltr' | 'rtl'

The document's text/writing direction.

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 focused date.

format

(date: DateValue[]) => string

The format of the date to display in the input.

getRootNode

() => ShadowRoot | Node | Document

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

id

string

The unique identifier of the machine.

ids

Partial<{ grid(id: string): string; header: string; content: string; cellTrigger(id: string): string; prevTrigger(view: DateView): string; nextTrigger(view: DateView): string; ... 7 more ...; positioner: string; }>

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

inline

boolean

Whether the calendar should be displayed inline.

isDateUnavailable

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

Returns whether a date of the calendar is available.

locale

string

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

max

DateValue

The maximum date that can be selected.

messages

IntlMessages

The localized messages to use.

min

DateValue

The minimum date that can be selected.

modal

boolean

Whether the calendar should be modal. This means that the calendar will block interaction with the rest of the page, and trap focus within it.

name

string

The `name` attribute of the input element.

numOfMonths

number

The number of months to display.

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.

parse

(value: string) => DateValue[]

The format of the date to display in the input.

positioning

PositioningOptions

The user provided options used to position the date picker content

readOnly

boolean

Whether the calendar is read-only.

selectionMode

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

startOfWeek

number

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

timeZone

string

The time zone to use

value

DateValue[]

The selected date(s).

view

DateView

The view of the calendar

DatePickerContext

clearTriggerProps

Dict<any>

clearValue

() => void

Clears the selected date(s).

close

() => void

Function to close the calendar.

contentProps

Dict<any>

controlProps

Dict<any>

focusedValue

DateValue

The focused date.

focusedValueAsDate

Date

The focused date as a Date object.

focusedValueAsString

string

The focused date as a string.

focusMonth

(month: number) => void

Function to set the selected month.

focusYear

(year: number) => void

Function to set the selected year.

format

(value: CalendarDate, opts?: DateTimeFormatOptions | undefined) => string

Formats the given date value based on the provided options.

getDayCellProps

(props: DayCellProps) => Dict<any>

getDayCellState

(props: DayCellProps) => DayCellState

Returns the state details for a given cell.

getDayCellTriggerProps

(props: DayCellProps) => Dict<any>

getDaysInWeek

(weekIndex: number, from?: DateValue | undefined) => DateValue[]

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

getDecade

() => { start: number | undefined; end: number | undefined }

Returns the start and end years of the decade.

getGridProps

(props?: GridProps | undefined) => Dict<any>

getHeaderProps

(props?: ViewProps | undefined) => Dict<any>

getMonthCellProps

(props: CellProps) => Dict<any>

getMonthCellState

(props: CellProps) => CellState

Returns the state details for a given month cell.

getMonthCellTriggerProps

(props: CellProps) => Dict<any>

getMonthDays

(from?: DateValue | undefined) => DateValue[][]

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

getMonths

(props?: { format?: 'short' | 'long' | undefined } | undefined) => GridItem[]

Returns the months of the year

getMonthsGrid

(props?: MonthGridProps | undefined) => MonthGridValue

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

getNextTriggerProps

(props?: ViewProps | undefined) => Dict<any>

getOffset

(months: number) => { amount: number visibleRange: { start: CalendarDate | CalendarDateTime | ZonedDateTime end: CalendarDate | CalendarDateTime | ZonedDateTime } weeks: DateValue[][] }

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

getPrevTriggerProps

(props?: ViewProps | undefined) => Dict<any>

getViewTriggerProps

(props?: ViewProps | undefined) => Dict<any>

getYearCellProps

(props: CellProps) => Dict<any>

getYearCellState

(props: CellProps) => CellState

getYearCellTriggerProps

(props: CellProps) => Dict<any>

getYears

() => GridItem[]

Returns the months of the year

getYearsGrid

(props?: YearGridProps | undefined) => YearGridValue

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

goToNext

() => void

Goes to the next month/year/decade.

goToPrev

() => void

Goes to the previous month/year/decade.

inputProps

Dict<any>

isFocused

boolean

Whether the input is focused

isUnavailable

(date: DateValue) => boolean

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

monthSelectProps

Dict<any>

open

() => void

Function to open the calendar.

positionerProps

Dict<any>

selectToday

() => void

Sets the selected date to today.

setFocusedValue

(value: CalendarDate) => void

Sets the focused date to the given date.

setValue

(values: CalendarDate[]) => void

Sets the selected date to the given date.

setView

(view: DateView) => void

Sets the view of the date picker.

triggerProps

Dict<any>

value

DateValue[]

The selected date.

valueAsDate

Date[]

The selected date as a Date object.

valueAsString

string[]

The selected date as a string.

view

DateView

The current view of the date picker

visibleRange

{ start: DateValue; end: DateValue }

The visible range of dates.

visibleRangeText

{ start: string; end: string; formatted: string }

The human readable text for the visible range of dates.

weekDays

{ value: CalendarDate | CalendarDateTime | ZonedDateTime short: string long: string narrow: string }[]

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

weeks

DateValue[][]

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

yearSelectProps

Dict<any>

isOpen

boolean

Whether the date picker is open

DatePickerGridProps

columns

number

id

string

view

DateView

DatePickerCellContext

value

number

disabled

boolean

DatePickerDayCellProps

value

DateValue

disabled

boolean

offset

Offset

DatePickerYearCellProps

value

number

disabled

boolean

DatePickerDayCellContext

value

DateValue

disabled

boolean

offset

Offset

DatePickerMonthCellProps

value

number

disabled

boolean

DatePickerPrevTriggerProps

view

DateView

DatePickerViewTriggerProps

view

DateView