Skip to main content
Kobalte

Date Picker

Since v2.0.0@kobalte/core/date-pickerSource

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";
// or
import { Root, Trigger, Value, Calendar, ... } from "@kobalte/core/date-picker";

Features

  • Supports single date, multiple dates, and date range selection modes.
  • Values are native JS Date objects (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.Content against, instead of the trigger.
  • DatePicker.Portal: Portals its children into the body when 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.

Select a meeting date.
<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.

style.css
.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.

PropDescription
selectionMode'single' | 'multiple' | 'range'
The type of selection that is allowed. Determines the shape of value/defaultValue/onChange. Default: 'single'
valueDateValue | DateValue[] | RangeValue<DateValue> | null
The controlled value of the date picker, shaped according to selectionMode.
defaultValueSame 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.
translationsDatePickerIntlTranslations
Localization strings.
localestring
The locale to display and select the date(s) according to. Defaults to the current i18n locale.
visibleDurationDateDuration
The amount of days/weeks/months displayed at once in the calendar. Affects how pagination works. Default: { months: 1 }
minValueDateValue
The minimum allowed date that a user may select.
maxValueDateValue
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.
allowsNonContiguousRangesboolean
In "range" selection mode, when combined with isDateUnavailable, whether non-contiguous ranges (ranges containing unavailable dates) may be selected.
closeOnSelectboolean
Whether the date picker should close automatically when a selection is made. Default: true for "single" and "range", false for "multiple".
placeholderValueDateValue
A placeholder date used to center the calendar when no value is selected yet. Defaults to today.
openboolean
The controlled open state of the date picker's popover.
defaultOpenboolean
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.
modalboolean
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.
preventScrollboolean
Whether the scroll should be locked even if the date picker is not modal.
forceMountboolean
Used to force mounting the date picker (portal, positioner and content) when more control is needed. Useful when controlling animation with SolidJS animation libraries.
idstring
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.
namestring
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.
requiredboolean
Whether the user must select a date before the owning form can be submitted.
disabledboolean
Whether the date picker is disabled.
readOnlyboolean
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.

PropDescription
getAnchorRect(anchor?: HTMLElement) => AnchorRect | undefined
Function that returns the anchor element's DOMRect.
placementPlacement
The placement of the date picker content. Default: "bottom-start"
gutternumber
The distance between the content and the trigger element. Default: 8
shiftnumber
The skidding of the content along the trigger element.
flipboolean | 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".
slideboolean
Whether the content should slide when it overflows.
overlapboolean
Whether the content can overlap the trigger element when it overflows.
sameWidthboolean
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
fitViewportboolean
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.
hideWhenDetachedboolean
Whether to hide the content when the trigger element becomes occluded.
detachedPaddingnumber
The minimum padding in order to consider the trigger element occluded.
arrowPaddingnumber
The minimum padding between the arrow and the content corner.
overflowPaddingnumber
The minimum padding between the content and the viewport edge. This will be exposed to CSS as --kb-popper-overflow-padding.
Data attributeDescription
data-validPresent when the date picker is valid according to the validation rules.
data-invalidPresent when the date picker is invalid according to the validation rules.
data-requiredPresent when the user must select a date before the owning form can be submitted.
data-disabledPresent when the date picker is disabled.
data-readonlyPresent 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 attributeDescription
data-expandedPresent when the date picker is open.
data-closedPresent 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 attributeDescription
data-placeholder-shownPresent 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.

PropDescription
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 attributeDescription
data-expandedPresent when the date picker is open.
data-closedPresent when the date picker is closed.

DatePicker.Arrow

Consists of Popover.Arrow.

PropDescription
sizenumber
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

ComponentDefault rendered element
DatePickerdiv
DatePicker.Labellabel
DatePicker.Descriptiondiv
DatePicker.ErrorMessagediv
DatePicker.Triggerbutton
DatePicker.Valuespan
DatePicker.Anchordiv
DatePicker.PortalPortal
DatePicker.Contentdiv
DatePicker.Arrowdiv
DatePicker.CloseButtonbutton
DatePicker.Calendar and sub-partssame as the equivalent Calendar component

Accessibility

Keyboard Interactions

KeyDescription
SpaceWhen focus is on the trigger, opens the date picker's calendar popover.
EnterWhen focus is on the trigger, opens the date picker's calendar popover.
TabMoves focus to the next focusable element.
Shift + TabMoves focus to the previous focusable element.
EscCloses 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 Calendar with Popover directly. DatePicker composes Kobalte's own Calendar and Popover the same way.

Last updated: 11/28/26, 9:28 PM