Liking cljdoc? Tell your friends :D

x-date-picker

A calendar date picker with single-date and date-range modes. Renders a text input that opens a floating calendar panel. Dates are represented as ISO 8601 strings (YYYY-MM-DD).


Tag

<x-date-picker></x-date-picker>

Attributes

AttributeTypeDefaultDescription
modeenum"single"Selection mode: single range
valuestringSelected date in YYYY-MM-DD format (single mode)
startstringRange start date in YYYY-MM-DD format (range mode)
endstringRange end date in YYYY-MM-DD format (range mode)
minstringMinimum selectable date (YYYY-MM-DD)
maxstringMaximum selectable date (YYYY-MM-DD)
formatenum"iso"Display format: iso (YYYY-MM-DD) or localized (via Intl)
localestringBCP 47 locale tag for localized formatting (e.g. "en-US")
separatorstring" - "String placed between start and end in range display
auto-swapbooleanfalseAutomatically swap start/end when end is selected before start
range-allow-same-daybooleanfalseAllow start and end to be the same date in range mode
close-on-selectbooleanfalseClose the calendar after a date is selected (single mode)
placeholderstringInput placeholder text
disabledbooleanfalseDisables the input and calendar
readonlybooleanfalseInput is read-only; calendar can still open but not select
requiredbooleanfalseMarks the field as required
namestringForm field name
autocompletestringHTML autocomplete hint
aria-labelstringAccessible label for the input
aria-describedbystringReferences a describing element

Properties

PropertyTypeReflects attribute
modestringmode
valuestringvalue
startstringstart
endstringend
disabledbooleandisabled
readOnlybooleanreadonly
requiredbooleanrequired
openbooleanopen

Events

EventCancelableDetailDescription
x-date-picker-inputno{ value?, start?, end?, mode }Fired on each user interaction
x-date-picker-change-requestyes{ value?, start?, end?, mode }Fired before committing a date selection
x-date-picker-changeno{ value?, start?, end?, mode }Fired after the selection is committed

Slots

SlotDescription
(default)No default slot content expected

Accessibility

  • The text input has role="combobox" with aria-expanded and aria-haspopup="dialog".
  • The calendar panel has role="dialog" with aria-modal="true".
  • Calendar cells have role="gridcell" with aria-selected and aria-disabled.
  • Full keyboard navigation within the calendar grid.

Keyboard (calendar open)

KeyAction
ArrowLeftMove one day back
ArrowRightMove one day forward
ArrowUpMove one week back
ArrowDownMove one week forward
PageUpMove one month back
PageDownMove one month forward
HomeGo to first day of week
EndGo to last day of week
Enter/SpaceSelect focused date
EscapeClose calendar without selecting
Click outsideClose calendar without selecting

Examples

Single date

<x-date-picker placeholder="Select a date"></x-date-picker>

Date range

<x-date-picker mode="range" placeholder="Select date range"></x-date-picker>

Pre-selected value

<x-date-picker value="2026-03-18"></x-date-picker>

Bounded range

<x-date-picker min="2026-01-01" max="2026-12-31"></x-date-picker>

Localized display

<x-date-picker format="localized" locale="en-US" placeholder="Pick a date"></x-date-picker>

Disabled

<x-date-picker disabled placeholder="Not available"></x-date-picker>

Listening to changes

document.querySelector('x-date-picker').addEventListener('x-date-picker-change', e => {
  console.log('selected date:', e.detail.value);
});

ClojureScript (hiccup renderer)

[:x-date-picker {:placeholder "Select a date"
                 :on-x-date-picker-change
                 (fn [e] (swap! state assoc :date (.. e -detail -value)))}]

[:x-date-picker {:mode "range"
                 :placeholder "Select date range"
                 :on-x-date-picker-change
                 (fn [e]
                   (swap! state assoc
                          :start (.. e -detail -start)
                          :end   (.. e -detail -end)))}]

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close