# Date Picker Select dates from a calendar interface. ```tsx import { DatePicker, Portal } from '@skeletonlabs/skeleton-react'; export default function Default() { return ( Label {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Controlled Manage the selected date value with React state. ```tsx import { DatePicker, parseDate, Portal } from '@skeletonlabs/skeleton-react'; import { useState } from 'react'; export default function Controlled() { const [value, setValue] = useState([parseDate('2025-10-15')]); return ( setValue(e.value)}> Picked date: {value.at(0)?.toString()} {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Disabled Disable the date picker to prevent user interaction. ```tsx import { DatePicker, Portal } from '@skeletonlabs/skeleton-react'; export default function Disabled() { return ( Label {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Minimum and Maximum Restrict date selection to a specific range using the `min` and `max` props with the `parseDate` helper function. ```tsx import { DatePicker, parseDate, Portal } from '@skeletonlabs/skeleton-react'; export default function MinMax() { return ( Label {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Range Selection Enable range selection by setting `selectionMode="range"` on the root component. Use two input fields with `index={0}` and `index={1}` to represent the start and end dates. ```tsx import { DatePicker, Portal } from '@skeletonlabs/skeleton-react'; export default function Range() { return ( Select Date Range {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Inline calendar Display the calendar inline without a popover by adding the `inline` prop to the root component. When using inline mode, omit the `Portal` and `Positioner` components. ```tsx import { DatePicker } from '@skeletonlabs/skeleton-react'; export default function Inline() { return ( Label {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Month and Year Selection Optionally add `` and `` components to provide dropdown selectors for quickly changing the month and year. ```tsx import { DatePicker, Portal } from '@skeletonlabs/skeleton-react'; export default function WithSelects() { return ( Label {(datePicker) => ( <> {datePicker.weekDays.map((weekDay, id) => ( {weekDay.short} ))} {datePicker.weeks.map((week, id) => ( {week.map((day, id) => ( {day.day} ))} ))} )} {(datePicker) => ( <> {datePicker.getMonthsGrid({ columns: 4, format: 'short' }).map((months, id) => ( {months.map((month, id) => ( {month.label} ))} ))} )} {(datePicker) => ( <> {datePicker.getYearsGrid({ columns: 4 }).map((years, id) => ( {years.map((year, id) => ( {year.label} ))} ))} )} ); } ``` ## Guidelines ### Portal The Date Picker content is rendered inside a [Portal](/docs/components/portal) component by default to avoid z-index stacking issues. The Portal renders the content at the end of the document body. ### Views The Date Picker supports three different views: * **Day view** - Select a specific day from the calendar * **Month view** - Select a month by clicking the view trigger when in day view * **Year view** - Select a year by clicking the view trigger when in month view Use the `` component with the `view` prop to define each view's layout. ### Context The `` component provides access to the date picker API for rendering dynamic content like weeks, months, and years grids. Use the render prop pattern to access the API. ### Parse Date Use the `parseDate` helper function to convert strings or Date objects to the appropriate date format. Zag.js adjusts this using [@internationalized/date](https://github.com/adobe/react-spectrum/tree/main/packages/@internationalized/date) under the hood. ```tsx import { parseDate } from '@skeletonlabs/skeleton-react'; const date = parseDate('2025-10-15'); const minDate = parseDate('2024-01-01'); const maxDate = parseDate('2024-12-31'); ``` ## API Reference ### DatePickerRootProps | Property | Default | Type | Description | | --------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | locale? | "en-US" | string \| undefined | The locale (BCP 47 language tag) to use when formatting the date. | | translations? | - | IntlTranslations \| undefined | The localized messages to use. | | ids? | - | Partial\<\{ root: string; label: (index: number) => string; table: (id: string) => string; tableHeader: (id: string) => string; tableBody: (id: string) => string; tableRow: (id: string) => string; ... 11 more ...; positioner: string; }> \| undefined | The ids of the elements in the date picker. Useful for composition. | | name? | - | string \| undefined | The \`name\` attribute of the input element. | | timeZone? | "UTC" | string \| undefined | The time zone to use | | disabled? | - | boolean \| undefined | Whether the calendar is disabled. | | readOnly? | - | boolean \| undefined | Whether the calendar is read-only. | | outsideDaySelectable? | false | boolean \| undefined | Whether day outside the visible range can be selected. | | min? | - | DateValue \| undefined | The minimum date that can be selected. | | max? | - | DateValue \| undefined | The maximum date that can be selected. | | closeOnSelect? | true | boolean \| undefined | Whether the calendar should close after the date selection is complete. This is ignored when the selection mode is \`multiple\`. | | value? | - | DateValue\[] \| undefined | The controlled selected date(s). | | defaultValue? | - | DateValue\[] \| undefined | The initial selected date(s) when rendered. Use when you don't need to control the selected date(s) of the date picker. | | focusedValue? | - | DateValue \| undefined | The controlled focused date. | | defaultFocusedValue? | - | DateValue \| undefined | The initial focused date when rendered. Use when you don't need to control the focused date of the date picker. | | numOfMonths? | - | number \| undefined | The number of months to display. | | startOfWeek? | - | number \| undefined | The first day of the week. \`0\` - Sunday \`1\` - Monday \`2\` - Tuesday \`3\` - Wednesday \`4\` - Thursday \`5\` - Friday \`6\` - Saturday | | fixedWeeks? | - | boolean \| undefined | Whether the calendar should have a fixed number of weeks. This renders the calendar with 6 weeks instead of 5 or 6. | | onValueChange? | - | ((details: ValueChangeDetails) => void) \| undefined | Function called when the value changes. | | onFocusChange? | - | ((details: FocusChangeDetails) => void) \| undefined | Function called when the focused date changes. | | onViewChange? | - | ((details: ViewChangeDetails) => void) \| undefined | Function called when the view changes. | | onOpenChange? | - | ((details: OpenChangeDetails) => void) \| undefined | Function called when the calendar opens or closes. | | isDateUnavailable? | - | ((date: DateValue, locale: string) => boolean) \| undefined | Returns whether a date of the calendar is available. | | selectionMode? | "single" | SelectionMode \| undefined | 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 | | format? | - | ((date: DateValue, details: LocaleDetails) => string) \| undefined | The format of the date to display in the input. | | parse? | - | ((value: string, details: LocaleDetails) => DateValue \| undefined) \| undefined | Function to parse the date from the input back to a DateValue. | | placeholder? | - | string \| undefined | The placeholder text to display in the input. | | view? | - | DateView \| undefined | The view of the calendar | | defaultView? | "day" | DateView \| undefined | The default view of the calendar | | minView? | "day" | DateView \| undefined | The minimum view of the calendar | | maxView? | "year" | DateView \| undefined | The maximum view of the calendar | | positioning? | - | PositioningOptions \| undefined | The user provided options used to position the date picker content | | open? | - | boolean \| undefined | The controlled open state of the date picker | | defaultOpen? | - | boolean \| undefined | 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. | | inline? | - | boolean \| undefined | Whether to render the date picker inline | | dir? | "ltr" | "ltr" \| "rtl" \| undefined | The document's text/writing direction. | | getRootNode? | - | (() => ShadowRoot \| Node \| Document) \| undefined | A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerRootProviderProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | value | - | DatePickerApi\ | - | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerRootContextProps | Property | Default | Type | Description | | -------- | ------- | ---------------------------------------------------- | ----------- | | children | - | (datePicker: DatePickerApi\) => ReactNode | - | ### DatePickerLabelProps | Property | Default | Type | Description | | -------- | ------- | ---------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"label">) => Element) \| undefined | Render the element yourself | ### DatePickerControlProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerPresetTriggerProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | value | - | PresetTriggerValue | - | | element? | - | ((attributes: HTMLAttributes\<"button">) => Element) \| undefined | Render the element yourself | ### DatePickerInputProps | Property | Default | Type | Description | | ---------- | ------- | ---------------------------------------------------------------- | --------------------------------------- | | index? | - | number \| undefined | The index of the input to focus. | | fixOnBlur? | true | boolean \| undefined | Whether to fix the input value on blur. | | element? | - | ((attributes: HTMLAttributes\<"input">) => Element) \| undefined | Render the element yourself | ### DatePickerTriggerProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"button">) => Element) \| undefined | Render the element yourself | ### DatePickerPositionerProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerContentProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerYearSelectProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"select">) => Element) \| undefined | Render the element yourself | ### DatePickerMonthSelectProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"select">) => Element) \| undefined | Render the element yourself | ### DatePickerViewProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | view? | - | DateView \| undefined | - | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerViewControlProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerPrevTriggerProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"button">) => Element) \| undefined | Render the element yourself | ### DatePickerViewTriggerProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"button">) => Element) \| undefined | Render the element yourself | ### DatePickerRangeTextProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself | ### DatePickerNextTriggerProps | Property | Default | Type | Description | | -------- | ------- | ----------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"button">) => Element) \| undefined | Render the element yourself | ### DatePickerTableProps | Property | Default | Type | Description | | -------- | ------- | ---------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"table">) => Element) \| undefined | Render the element yourself | ### DatePickerTableHeadProps | Property | Default | Type | Description | | -------- | ------- | ---------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"thead">) => Element) \| undefined | Render the element yourself | ### DatePickerTableRowProps | Property | Default | Type | Description | | -------- | ------- | ------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"tr">) => Element) \| undefined | Render the element yourself | ### DatePickerTableHeaderProps | Property | Default | Type | Description | | -------- | ------- | ------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"th">) => Element) \| undefined | Render the element yourself | ### DatePickerTableBodyProps | Property | Default | Type | Description | | -------- | ------- | ---------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"tbody">) => Element) \| undefined | Render the element yourself | ### DatePickerTableCellProps | Property | Default | Type | Description | | ------------- | ------- | ------------------------------------------------------------- | --------------------------- | | disabled? | - | boolean \| undefined | - | | value | - | number \| DateValue | - | | columns? | - | number \| undefined | - | | visibleRange? | - | VisibleRange \| undefined | - | | element? | - | ((attributes: HTMLAttributes\<"td">) => Element) \| undefined | Render the element yourself | ### DatePickerTableCellTriggerProps | Property | Default | Type | Description | | -------- | ------- | -------------------------------------------------------------- | --------------------------- | | element? | - | ((attributes: HTMLAttributes\<"div">) => Element) \| undefined | Render the element yourself |