Combines a Calendar with a Popover so the user can pick a date, dates, or a date range from a trigger button.
Import
import { DatePicker } from "@kobalte/core/date-picker";// orimport { Root, Trigger, Value, Calendar, ... } from "@kobalte/core/date-picker";Features
- Supports single date, multiple dates, and date range selection modes.
- Values are native JS
Dateobjects (Gregorian calendar only) rather than a separate date library's types. - The selected value is displayed as formatted, human-readable text by
DatePicker.Value— never a raw editable segment. - Closes automatically on selection, configurable via
closeOnSelect. - Support for minimum and maximum dates, and arbitrary unavailable dates.
- Labeling support for accessibility.
- Support for description and error message help text linked to the trigger via ARIA.
- Browser form integration via a hidden native
<input>. - Can be controlled or uncontrolled.
Anatomy
The date picker consists of:
- DatePicker: The root container for a date picker.
- DatePicker.Label: The label that gives the user information on the date picker.
- DatePicker.Trigger: The button that opens the date picker's calendar popover.
- DatePicker.Value: Displays the formatted selected value, falling back to its children as placeholder when nothing is selected.
- DatePicker.Description: The description that gives the user more information on the date picker.
- DatePicker.ErrorMessage: The error message that gives the user information about how to fix a validation error.
- DatePicker.Anchor: An optional element to position the
DatePicker.Contentagainst, instead of the trigger. - DatePicker.Portal: Portals its children into the
bodywhen the date picker is open. - DatePicker.Content: Contains the content to be rendered when the date picker is open.
- DatePicker.Arrow: An optional arrow element to render alongside the content.
- DatePicker.CloseButton: An optional button that closes the date picker.
- DatePicker.Calendar: Wraps the Calendar used to pick the date(s), and closes the popover on selection according to
closeOnSelect.
<DatePicker> <DatePicker.Label /> <DatePicker.Anchor /> <DatePicker.Trigger> <DatePicker.Value /> </DatePicker.Trigger> <DatePicker.Description /> <DatePicker.ErrorMessage /> <DatePicker.Portal> <DatePicker.Content> <DatePicker.Arrow /> <DatePicker.CloseButton /> <DatePicker.Calendar> {/* same anatomy as the standalone Calendar component */} </DatePicker.Calendar> </DatePicker.Content> </DatePicker.Portal></DatePicker>DatePicker.Calendar's children follow the exact same anatomy as the standalone Calendar component (DatePicker.CalendarHeader, DatePicker.CalendarGrid, DatePicker.CalendarGridBodyCellTrigger, etc. — these are aliases re-exported from Calendar.*).
Example
export function BasicExample() { return ( <DatePicker class={style["date-picker"]} selectionMode="single"> <DatePicker.Label class={style["date-picker__label"]}> Event date </DatePicker.Label> <DatePicker.Trigger class={style["date-picker__trigger"]}> <DatePicker.Value class={style["date-picker__value"]}> Pick a date </DatePicker.Value> </DatePicker.Trigger> <DatePicker.Portal> <DatePicker.Content class={style["date-picker__content"]}> <DatePicker.Arrow /> <DatePicker.Calendar> <DatePicker.CalendarHeader class={calendarStyle.calendar__header}> <DatePicker.CalendarPrevTrigger class={calendarStyle.calendar__trigger} > {"<"} </DatePicker.CalendarPrevTrigger> <DatePicker.CalendarHeading class={calendarStyle.calendar__heading} /> <DatePicker.CalendarNextTrigger class={calendarStyle.calendar__trigger} > {">"} </DatePicker.CalendarNextTrigger> </DatePicker.CalendarHeader> <DatePicker.CalendarBody> <DatePicker.CalendarGrid class={calendarStyle.calendar__grid}> <DatePicker.CalendarGridHeader> <DatePicker.CalendarGridHeaderRow> {(weekDay) => ( <DatePicker.CalendarGridHeaderCell class={calendarStyle["calendar__grid-header-cell"]} > {weekDay()} </DatePicker.CalendarGridHeaderCell> )} </DatePicker.CalendarGridHeaderRow> </DatePicker.CalendarGridHeader> <DatePicker.CalendarGridBody> {(weekIndex) => ( <DatePicker.CalendarGridBodyRow weekIndex={weekIndex()}> {(date) => ( <Show when={date()} fallback={ <td class={calendarStyle["calendar__grid-body-cell"]} /> } > <DatePicker.CalendarGridBodyCell date={date()!} class={calendarStyle["calendar__grid-body-cell"]} > <DatePicker.CalendarGridBodyCellTrigger class={ calendarStyle[ "calendar__grid-body-cell-trigger" ] } /> </DatePicker.CalendarGridBodyCell> </Show> )} </DatePicker.CalendarGridBodyRow> )} </DatePicker.CalendarGridBody> </DatePicker.CalendarGrid> </DatePicker.CalendarBody> </DatePicker.Calendar> </DatePicker.Content> </DatePicker.Portal> </DatePicker> );}.date-picker { display: flex; flex-direction: column; gap: 4px;}
.date-picker__label { color: hsl(240 6% 10%); font-size: 14px; font-weight: 500; user-select: none;}
.date-picker__trigger { display: inline-flex; align-items: center; justify-content: space-between; width: 220px; border-radius: 6px; padding: 0 10px; min-height: 36px; outline: none; forced-color-adjust: none; background-color: #fff; border: 1px solid hsl(240 6% 90%); color: hsl(240 4% 16%); font-size: 14px; cursor: pointer; transition: border-color 250ms, color 250ms;}
.date-picker__trigger:hover { border-color: hsl(240 5% 65%);}
.date-picker__trigger:focus-visible { outline: 2px solid hsl(200 98% 39%); outline-offset: 2px;}
.date-picker__trigger[data-disabled] { background-color: hsl(240 5% 96%); color: hsl(240 4% 46%); cursor: default;}
.date-picker__trigger[data-invalid] { border-color: hsl(0 72% 51%); color: hsl(0 72% 51%);}
.date-picker__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.date-picker__value[data-placeholder-shown] { color: hsl(240 4% 46%); font-style: italic;}
.date-picker__description { color: hsl(240 5% 26%); font-size: 12px; user-select: none;}
.date-picker__error-message { color: hsl(0 72% 51%); font-size: 12px; user-select: none;}
.date-picker__content { background-color: white; border-radius: 6px; border: 1px solid hsl(240 6% 90%); box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); transform-origin: var(--kb-popover-content-transform-origin); padding: 12px;}
[data-theme*="dark"] .date-picker__label { color: hsl(240 5% 84%);}
[data-theme*="dark"] .date-picker__trigger { background-color: hsl(240 4% 16%); border: 1px solid hsl(240 5% 34%); color: hsl(0 100% 100% / 0.9);}
[data-theme*="dark"] .date-picker__trigger:hover { border-color: hsl(240 5% 34%);}
[data-theme*="dark"] .date-picker__value[data-placeholder-shown] { color: hsl(0 100% 100% / 0.5);}
[data-theme*="dark"] .date-picker__description { color: hsl(240 5% 65%);}
[data-theme*="dark"] .date-picker__content { background-color: hsl(240 4% 16%); border: 1px solid hsl(240 5% 34%);}.calendar { display: inline-flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: 6px; background-color: #fff; border: 1px solid hsl(240 6% 90%); color: hsl(240 4% 16%); font-size: 14px;}
.calendar[data-disabled] { opacity: 0.5;}
.calendar__header { display: flex; align-items: center; justify-content: space-between; padding: 0 4px;}
.calendar__heading { font-size: 14px; font-weight: 500; margin: 0;}
.calendar__trigger { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; border: 1px solid hsl(240 6% 90%); background-color: #fff; color: hsl(240 4% 16%); cursor: pointer;}
.calendar__trigger:hover { background-color: hsl(240 5% 96%);}
.calendar__trigger[disabled] { opacity: 0.4; cursor: not-allowed;}
.calendar__grid { border-collapse: collapse;}
.calendar__grid-header-cell { font-size: 12px; font-weight: 500; color: hsl(240 4% 46%); padding: 4px; text-align: center;}
.calendar__grid-body-cell { padding: 2px; text-align: center;}
.calendar__grid-body-cell-trigger { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; outline: none; cursor: pointer; user-select: none;}
.calendar__grid-body-cell-trigger[data-outside-month] { color: hsl(240 5% 65%);}
.calendar__grid-body-cell-trigger[data-today] { font-weight: 700;}
.calendar__grid-body-cell-trigger[data-highlighted] { outline: 2px solid hsl(200 98% 39%); outline-offset: -1px;}
.calendar__grid-body-cell-trigger[data-selected] { background-color: hsl(200 98% 39%); color: #fff;}
.calendar__grid-body-cell-trigger[data-selection-start],.calendar__grid-body-cell-trigger[data-selection-end] { background-color: hsl(200 98% 39%); color: #fff;}
.calendar__grid-body-cell-trigger[data-disabled],.calendar__grid-body-cell-trigger[data-unavailable] { color: hsl(240 5% 65%); opacity: 0.5; cursor: not-allowed; text-decoration: line-through;}
.calendar__grid-body-cell-trigger[data-weekend]:not([data-outside-month]) { color: hsl(0 72% 51%);}
[data-theme*="dark"] .calendar { background-color: hsl(240 4% 16%); border: 1px solid hsl(240 5% 34%); color: hsl(0 100% 100% / 0.9);}
[data-theme*="dark"] .calendar__trigger { background-color: hsl(240 4% 16%); border: 1px solid hsl(240 5% 34%); color: hsl(0 100% 100% / 0.9);}
[data-theme*="dark"] .calendar__trigger:hover { background-color: hsl(240 5% 26%);}
[data-theme*="dark"] .calendar__grid-header-cell { color: hsl(240 5% 65%);}
[data-theme*="dark"] .calendar__grid-body-cell-trigger[data-outside-month] { color: hsl(240 5% 45%);}
[data-theme*="dark"] .calendar__grid-body-cell-trigger[data-disabled],[data-theme*="dark"] .calendar__grid-body-cell-trigger[data-unavailable] { color: hsl(240 5% 45%);}Usage
Selection mode
The selectionMode prop controls what kind of value is picked, and the shape of value / defaultValue / onChange changes accordingly:
"single"(default):DateValue | null"multiple":DateValue[] | null"range":RangeValue<DateValue> | null
DatePicker.Value formats whichever shape is selected automatically: a single formatted date, a comma-joined list of dates, or "start – end" for a range.
<DatePicker selectionMode="multiple"> <DatePicker.Label>Event dates</DatePicker.Label> {/* ...trigger, portal, content, calendar... */}</DatePicker><DatePicker selectionMode="range"> <DatePicker.Label>Trip dates</DatePicker.Label> {/* ...trigger, portal, content, calendar... */}</DatePicker>By default, the popover closes automatically after a complete selection for "single" and "range", but stays open for "multiple" so several dates can be picked in a row. Override this with the closeOnSelect prop.
Default value
An initial, uncontrolled value can be provided using the defaultValue prop.
<DatePicker selectionMode="single" defaultValue={new Date(2024, 5, 15)}> ...</DatePicker>Controlled value
The value prop, combined with onChange, can be used to make the value controlled.
import { createSignal } from "solid-js";
function ControlledExample() { const [value, setValue] = createSignal<Date | null>(null);
return ( <DatePicker selectionMode="single" value={value()} onChange={setValue}> ... </DatePicker> );}Minimum and maximum dates
Use the minValue and maxValue props to restrict the range of selectable dates. Dates outside this range are rendered disabled in the calendar.
<DatePicker selectionMode="single" defaultValue={new Date(2024, 5, 15)} minValue={new Date(2024, 0, 1)} maxValue={new Date(2024, 11, 31)}> ...</DatePicker>Unavailable dates
The isDateUnavailable callback can mark arbitrary dates as unavailable, for example to block out weekends or specific days.
<DatePicker selectionMode="single" isDateUnavailable={date => date.getDay() === 0 || date.getDay() === 6}> ...</DatePicker>In "range" selection mode, allowsNonContiguousRanges controls whether a range that spans over unavailable dates can be selected.
Description
The DatePicker.Description component can be used to associate additional help text with a date picker.
<DatePicker selectionMode="single"> <DatePicker.Label>Date</DatePicker.Label> {/* ...trigger, portal, content, calendar... */} <DatePicker.Description>Select a meeting date.</DatePicker.Description></DatePicker>Error message
The DatePicker.ErrorMessage component can be used to help the user fix a validation error. It should be combined with the validationState prop to semantically mark the date picker as invalid for assistive technologies.
By default, it will render only when validationState is set to "invalid"; use the forceMount prop to always render it (e.g. for usage with animation libraries).
import { createSignal } from "solid-js";
function ErrorMessageExample() { const [value, setValue] = createSignal<Date | undefined>(undefined);
return ( <DatePicker selectionMode="single" value={value() ?? null} onChange={setValue} validationState={value() === undefined ? "invalid" : "valid"} > <DatePicker.Label>Date</DatePicker.Label> {/* ...trigger, portal, content, calendar... */} <DatePicker.ErrorMessage>Please select a date.</DatePicker.ErrorMessage> </DatePicker> );}Disabled
<DatePicker selectionMode="single" disabled> <DatePicker.Label>Date</DatePicker.Label> {/* ...trigger, portal, content, calendar... */}</DatePicker>HTML forms
The name prop, paired with a hidden native <input> rendered automatically by the root, can be used for integration with HTML forms. Since there's no segmented text input, the value is serialized as an ISO date string ("single"), a comma-joined list ("multiple"), or "start/end" ("range").
<form onSubmit={handleSubmit}> <DatePicker selectionMode="single" name="event-date"> ... </DatePicker></form>Origin-aware animations
Since DatePicker.Content is Kobalte's Popover.Content under the hood, the same --kb-popover-content-transform-origin CSS custom property is exposed and can be used to animate the content from its computed origin.
.date-picker__content { transform-origin: var(--kb-popover-content-transform-origin); animation: contentHide 250ms ease-in forwards;}
.date-picker__content[data-expanded] { animation: contentShow 250ms ease-out;}
@keyframes contentShow { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); }}
@keyframes contentHide { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); }}API Reference
DatePicker
DatePicker is equivalent to the Root import from @kobalte/core/date-picker.
| Prop | Description |
|---|---|
| selectionMode | 'single' | 'multiple' | 'range' The type of selection that is allowed. Determines the shape of value/defaultValue/onChange. Default: 'single' |
| value | DateValue | DateValue[] | RangeValue<DateValue> | null The controlled value of the date picker, shaped according to selectionMode. |
| defaultValue | Same as value The value when initially rendered. Useful when you do not need to control the value. |
| onChange | (value) => void Event handler called when the value changes. |
| translations | DatePickerIntlTranslations Localization strings. |
| locale | string The locale to display and select the date(s) according to. Defaults to the current i18n locale. |
| visibleDuration | DateDuration The amount of days/weeks/months displayed at once in the calendar. Affects how pagination works. Default: { months: 1 } |
| minValue | DateValue The minimum allowed date that a user may select. |
| maxValue | DateValue The maximum allowed date that a user may select. |
| isDateUnavailable | (date: DateValue) => boolean Callback called for each date of the calendar. If it returns true, the date is unavailable. |
| allowsNonContiguousRanges | boolean In "range" selection mode, when combined with isDateUnavailable, whether non-contiguous ranges (ranges containing unavailable dates) may be selected. |
| closeOnSelect | boolean Whether the date picker should close automatically when a selection is made. Default: true for "single" and "range", false for "multiple". |
| placeholderValue | DateValue A placeholder date used to center the calendar when no value is selected yet. Defaults to today. |
| open | boolean The controlled open state of the date picker's popover. |
| defaultOpen | boolean The default open state when initially rendered. Useful when you do not need to control the open state. |
| onOpenChange | (open: boolean) => void Event handler called when the open state of the date picker changes. |
| modal | boolean Whether the date picker's popover should be the only visible content for screen readers, when set to true: - interaction with outside elements will be disabled. - scroll will be locked. - focus will be locked inside the content. - elements outside the content will not be visible for screen readers. |
| preventScroll | boolean Whether the scroll should be locked even if the date picker is not modal. |
| forceMount | boolean Used to force mounting the date picker (portal, positioner and content) when more control is needed. Useful when controlling animation with SolidJS animation libraries. |
| id | string A unique identifier for the component. The id is used to generate id attributes for nested components. If no id prop is provided, a generated id will be used. |
| name | string The name of the date picker. Submitted with its owning form as part of a name/value pair via a hidden native <input>. |
| validationState | 'valid' | 'invalid' Whether the date picker should display its "valid" or "invalid" visual styling. |
| required | boolean Whether the user must select a date before the owning form can be submitted. |
| disabled | boolean Whether the date picker is disabled. |
| readOnly | boolean Whether the date picker's calendar can be viewed but not changed by the user. |
DatePicker also accepts the following props to customize the placement of the DatePicker.Content, forwarded to its internal Popover.
| Prop | Description |
|---|---|
| getAnchorRect | (anchor?: HTMLElement) => AnchorRect | undefined Function that returns the anchor element's DOMRect. |
| placement | Placement The placement of the date picker content. Default: "bottom-start" |
| gutter | number The distance between the content and the trigger element. Default: 8 |
| shift | number The skidding of the content along the trigger element. |
| flip | boolean | string Controls the behavior of the content when it overflows the viewport: - If a boolean, specifies whether the content should flip to the opposite side when it overflows.- If a string, indicates the preferred fallback placements when it overflows. The placements must be spaced-delimited, e.g. "top left". |
| slide | boolean Whether the content should slide when it overflows. |
| overlap | boolean Whether the content can overlap the trigger element when it overflows. |
| sameWidth | boolean Whether the content should have the same width as the trigger element. This will be exposed to CSS as --kb-popper-anchor-width. Default: false |
| fitViewport | boolean Whether the content should fit the viewport. If set to true, the content will have maxWidth and maxHeight set to the viewport size. This will be exposed to CSS as --kb-popper-available-width and --kb-popper-available-height. |
| hideWhenDetached | boolean Whether to hide the content when the trigger element becomes occluded. |
| detachedPadding | number The minimum padding in order to consider the trigger element occluded. |
| arrowPadding | number The minimum padding between the arrow and the content corner. |
| overflowPadding | number The minimum padding between the content and the viewport edge. This will be exposed to CSS as --kb-popper-overflow-padding. |
| Data attribute | Description |
|---|---|
| data-valid | Present when the date picker is valid according to the validation rules. |
| data-invalid | Present when the date picker is invalid according to the validation rules. |
| data-required | Present when the user must select a date before the owning form can be submitted. |
| data-disabled | Present when the date picker is disabled. |
| data-readonly | Present when the date picker is read only. |
DatePicker.Label, DatePicker.Trigger, DatePicker.Value, DatePicker.Description and DatePicker.ErrorMessage share the same form-control data-attributes.
DatePicker.Trigger
DatePicker.Trigger consists of Popover.Trigger, itself built on Button.
| Data attribute | Description |
|---|---|
| data-expanded | Present when the date picker is open. |
| data-closed | Present when the date picker is closed. |
DatePicker.Value
Displays the formatted selected value; renders its children as placeholder content when nothing is selected yet.
| Data attribute | Description |
|---|---|
| data-placeholder-shown | Present when the date picker's placeholder is visible (no value selected). |
DatePicker.Anchor
An optional element to position DatePicker.Content against when you do not want to use the trigger as the anchor. Consists of Popover.Anchor.
DatePicker.Portal
Portals DatePicker.Content into the body when the date picker is open. Consists of Popover.Portal.
DatePicker.Content
Consists of Popover.Content. The popper positioner will copy the same z-index as DatePicker.Content.
| Prop | Description |
|---|---|
| onOpenAutoFocus | (event: Event) => void Event handler called when focus moves into the component after opening. It can be prevented by calling event.preventDefault. |
| onCloseAutoFocus | (event: Event) => void Event handler called when focus moves to the trigger after closing. It can be prevented by calling event.preventDefault. |
| onEscapeKeyDown | (event: KeyboardEvent) => void Event handler called when the escape key is down. It can be prevented by calling event.preventDefault. |
| onPointerDownOutside | (event: PointerDownOutsideEvent) => void Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault. |
| onFocusOutside | (event: FocusOutsideEvent) => void Event handler called when the focus moves outside the bounds of the component. It can be prevented by calling event.preventDefault. |
| onInteractOutside | (event: InteractOutsideEvent) => void Event handler called when an interaction (pointer or focus event) happens outside the bounds of the component. It can be prevented by calling event.preventDefault. |
| Data attribute | Description |
|---|---|
| data-expanded | Present when the date picker is open. |
| data-closed | Present when the date picker is closed. |
DatePicker.Arrow
Consists of Popover.Arrow.
| Prop | Description |
|---|---|
| size | number The size of the arrow. |
DatePicker.CloseButton
An optional button that closes the date picker when pressed. Consists of Popover.CloseButton, itself built on Button.
DatePicker.Calendar
Wraps the standalone Calendar component with the date picker's selection state, and closes the popover on selection according to closeOnSelect. Rendered inside DatePicker.Content.
All DatePicker.Calendar* sub-parts (DatePicker.CalendarHeader, DatePicker.CalendarHeading, DatePicker.CalendarPrevTrigger, DatePicker.CalendarNextTrigger, DatePicker.CalendarBody, DatePicker.CalendarGrid, DatePicker.CalendarGridHeader, DatePicker.CalendarGridHeaderRow, DatePicker.CalendarGridHeaderCell, DatePicker.CalendarGridBody, DatePicker.CalendarGridBodyRow, DatePicker.CalendarGridBodyCell, DatePicker.CalendarGridBodyCellTrigger) are aliases for the equivalent Calendar sub-components, and share the exact same props and data-attributes — refer to the Calendar docs for their full API reference rather than this page.
Rendered elements
| Component | Default rendered element |
|---|---|
DatePicker | div |
DatePicker.Label | label |
DatePicker.Description | div |
DatePicker.ErrorMessage | div |
DatePicker.Trigger | button |
DatePicker.Value | span |
DatePicker.Anchor | div |
DatePicker.Portal | Portal |
DatePicker.Content | div |
DatePicker.Arrow | div |
DatePicker.CloseButton | button |
DatePicker.Calendar and sub-parts | same as the equivalent Calendar component |
Accessibility
Keyboard Interactions
| Key | Description |
|---|---|
| Space | When focus is on the trigger, opens the date picker's calendar popover. |
| Enter | When focus is on the trigger, opens the date picker's calendar popover. |
| Tab | Moves focus to the next focusable element. |
| Shift + Tab | Moves focus to the previous focusable element. |
| Esc | Closes the date picker's calendar popover and moves focus back to the trigger. |
Once open, keyboard navigation inside the calendar grid (arrow keys to move between dates, PageUp/PageDown to change month, Enter/Space to select, etc.) is identical to the standalone Calendar component — refer to its Keyboard Interactions section for the full table.
corvu has no dedicated date-picker primitive — its docs instead suggest combining
CalendarwithPopoverdirectly.DatePickercomposes Kobalte's ownCalendarandPopoverthe same way.
Last updated: 11/28/26, 9:28 PM