Date picker

stable 6.1 kB
<hk-date-picker>

A calendar that gets the boring parts right: correct leading blanks per month, a configurable first day of the week, and range selection that survives picking the end before the start. `mode` changes what a click means — one day, several, or a span — while the grid and the month arithmetic stay identical. Time folds into every selected date rather than sitting beside it, so a timestamp is a real instant and not a date at midnight.

#calendar#date
In the package npm i hellskitchen-ui Import hk-date-picker and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
valueDate | Date[] | nullnullSelected date, or range start; a Date[] in multiple mode. Two-way bindable.
rangeEndDate | nullnullRange end. Two-way bindable, and only used in range mode.
mode'single' | 'multiple' | 'range''single'What a click means. The grid and the month arithmetic are identical in all three.
showTimebooleanfalseAdds hour and minute controls, folded into every selected date — so a timestamp is a real instant, not a date at midnight.
hourFormat'12' | '24''24'Clock used by the time controls.
format'dd/MM/yyyy' | 'yyyy-MM-dd' | 'iso' | 'timestamp' | string'dd/MM/yyyy'Shape of the (dateChange) value. A custom pattern of yyyy, MM, dd, HH and mm is accepted; `timestamp` emits epoch milliseconds and `iso` emits ISO 8601.
min / maxDate | nullnullSelectable bounds; outside days are disabled, not hidden.
firstDay'sunday' | 'monday''monday'Which column the week starts in.
localestring'en-US'Drives month and weekday names.

Outputs

  • valueChange / rangeEndChangeEventEmitter<Date | Date[] | null>

    Emits on pick.

  • dateChangeEventEmitter<HkDatePickerOutput>

    The selection rendered in `format`: one value in single mode, an array otherwise. Emits on every change, including the first render.

Keyboard

  • Tab Moves through the month controls and the days
  • Enter / Space Selects the focused day

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-date-selected#dc2626Selected day fill.
--hk-date-in-rangergb(220 38 38 / 0.10)Days between the two ends.
--hk-date-today-ring#94a3b8Outline on today.

Accessibility

  • Every day is a button labelled with its full date, so a screen reader says "Monday, September 14, 2026" rather than "14".
  • Date-only values are anchored to local midnight — the same fix the table filter needed, since a UTC-parsed date lands on the previous day west of UTC.
  • Disabled days are announced as disabled rather than silently ignoring the click.

More in Forms