Date range picker
Start and end dates, typed or picked as one range.
Example
<div class="stack"> <focsd-date-range-picker label="Trip dates" value-start="2026-05-04" value-end="2026-05-08" locale="en-GB"></focsd-date-range-picker></div>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-date-range-picker.js';</script>
<focsd-date-range-picker label="Trip dates" value-start="2026-05-04" value-end="2026-05-08" locale="en-GB"></focsd-date-range-picker>import { DateRangePicker } from '@focsd-dev/react';
export function Example() { return <DateRangePicker onChange={(e) => console.log(e.target)} label="Trip dates" value-start="2026-05-04" value-end="2026-05-08" locale="en-GB"></DateRangePicker>;}<script setup>import '@focsd-dev/components/focsd-date-range-picker.js';</script>
<template> <focsd-date-range-picker @change="onChange" label="Trip dates" value-start="2026-05-04" value-end="2026-05-08" locale="en-GB"></focsd-date-range-picker></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-date-range-picker.js';
// template<focsd-date-range-picker (change)="onChange($event)" label="Trip dates" value-start="2026-05-04" value-end="2026-05-08" locale="en-GB"></focsd-date-range-picker><script> import '@focsd-dev/components/focsd-date-range-picker.js';</script>
<focsd-date-range-picker onchange={(e) => console.log(e.target)} label="Trip dates" value-start="2026-05-04" value-end="2026-05-08" locale="en-GB"></focsd-date-range-picker>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
value-start | valueStart | string | — |
value-end | valueEnd | string | — |
name | name | string | — |
disabled | disabled | boolean | false |
required | required | boolean | false |
readonly | readOnly | boolean | false |
aria-label | hostAriaLabel | string | null | null |
aria-description | hostAriaDescription | string | null | null |
aria-labelledby | hostAriaLabelledBy | string | null | null |
aria-describedby | hostAriaDescribedBy | string | null | null |
label-position | labelPosition | 'top' | 'start' | 'end' | undefined | — |
hint | hint | string | — |
error | error | — | — |
warning | warning | string | undefined | — |
success | success | string | undefined | — |
error-message | errorMessage | string | undefined | — |
warning-message | warningMessage | string | undefined | — |
warning-pattern | warningPattern | string | undefined | — |
label | label | string | — |
value | value | string | — |
min | min | string | — |
max | max | string | — |
locale | locale | string | — |
step | step | number | 1 |
autocomplete | autocomplete | AutoFill | off |
Methods
| Method | Description |
|---|---|
describedByIds() | IDs to add to the inner control's aria-describedby: the hint, then the shown message. |
checkValidity() | True when the value is valid; otherwise fires invalid and returns false, like native. |
reportValidity() | Like checkValidity(), and also shows the browser's validation message when invalid. |
setCustomValidity(message) | Set (non-empty) or clear (empty string) a custom validation error, like native controls. |
setValidityState(flags, message, anchor) | For subclasses: set the validity flags and message. anchor is the element the browser points its message at. |
validate() | Show (or clear) the error from the control's own checks: required, type, pattern, min,
max and the like. Uses error-message, else the browser's localized message. An error the
author set (a server error, say) is left as it is. |
clearValidation() | Clear the error and warning that validate() and warning-pattern showed (a form reset does). |
emitValue(commit) | For subclasses: fire the value events, as a native control does on a user edit: input
(bubbles, composed), then with commit also change (bubbles, stays in its tree). |
idrefText(ids) | For subclasses: the text of the elements an ID reference list names, resolved in the host's tree (ID references cannot cross a shadow root), joined by spaces. |
showPicker() | Open the calendar from code, like native showPicker(). |
openDialog() | Open the calendar dialog and focus its active day. Does nothing while disabled or read-only. |
Events
| Event | Description |
|---|---|
input | Fired on every user edit of the value. |
change | Fired when the user commits a change to the value or state. |
CSS parts
Style the inside of the component with ::part(), for example focsd-date-range-picker::part(field).
| Part | Description |
|---|---|
field | The field element. |
group | The group element. |
label | The label element. |
range | Added to the field of a date range picker. |
sublabel | The "Start date" and "End date" labels. |
calendar | The calendar inside the dialog. |
calendar-day | Calendar parts, re-exported with a `calendar-` prefix (calendar-day, calendar-nav, calendar-heading, calendar-grid, calendar-weekday, calendar-today, calendar-selected, …). |
panel | The dialog's content: the calendar, any extra fields and the actions. |
actions | The row of dialog buttons at the bottom. |
cancel | The dialog's Cancel button (also exposed as `close`). |
close | The dialog's Cancel button (kept for existing stylesheets). |
control | The control element. |
dialog | The dialog element. |
layout | The wrapper that places the label beside or above the body. |
body | The control, hint and message. |
hint | The author hint followed by the date format. |
message | The shown error, warning or success message (also `error`, `warning` or `success`). |
message-icon | The message's icon. |
announcer | The visually hidden status region. |
trigger | The trigger element. |
Accessibility
autocompleteis forwarded to both inputs.- A
role="group"named by the label, with two labeled inputs ("Start date", "End date") and one "Choose dates" button. - In the dialog the first pick sets the start and the second the end; every day in the range is
aria-selected. - The form receives
<name>-startand<name>-end. - Form-associated: participates in
FormData, validation, reset, fieldsetdisabledand back/forward restore.
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.