Skip to
Keyboard shortcuts

Use the up and down arrow keys to move between items. Press Alt+Shift+K to open this list again.

Alpha version out now. The API may still change.

DateRangePicker

A button after a From and a To date field that opens a calendar in a dialog, so a start and an end can be picked. Choosing the start and the end fills in both fields. Typing always works: the picker is an extra way to give the dates, not a replacement.

Package
@kvirn-ui/react
Pattern
APG Date Picker Dialog
Testing
Automated. Core 0 of 2, Release 0 of 3

When to use it#

  • Use it for a start and an end near today, such as a stay or a leave, with a typed field for each end. You keep the form state: the picker reads both fields and gives back the finished range.
  • Use it in forms for residents and for staff. Put the two fields in a group Fieldset whose legend names the range.
  • Not for one date: use DatePicker.
  • Not for a range far from today: let people type it.
  • Not when most days are taken: offer the free periods as radio buttons.
  • Not as a section of the page: use a Calendar with mode="range".

Example#

Dates of your stay (optional)

For example 27/10/2026

For example 27/10/2026

Choose the dates

Use cases#

A stay with a longest length

Set maximumDays and write the limit in your own unit in the group’s help text. Days count both ends, so a booking of 14 nights is 15 days. The dialog writes the limit in days. Someone can still type a reversed or too long range. The example checks it when the form is sent and puts the error on the To field. It fixes today, so the dates are the same on any day.

Dates of your stay (optional)

For example 27/10/2026

For example 27/10/2026

Stays are up to 14 nights, from 14 October 2026.

Choose the dates

Props in this example:

Warning: Don't forget

The picker never checks what is typed, so a reversed or too long range reaches your form (3.3.1 Error Identification). Check it, and say what is wrong and how to fix it. See What you need to do.

Days that are taken

A day that can’t be chosen stays reachable with the keyboard and shows as unavailable (struck through in the default theme). The reason is part of its name, so a screen reader reads it. By default a range cannot pass over such a day. Set allowUnavailableInRange when it can, such as a leave across a holiday.

Dates of your stay (optional)

For example 27/10/2026

For example 27/10/2026

Choose the dates

Props in this example:

A dialog title that asks your question

The default title says “Choose the dates”. A title that repeats the group’s question tells the user which dates they are choosing.

Dates of your stay (optional)

For example 27/10/2026

For example 27/10/2026

Choose the dates of your stay

Props in this example:

Information: Did you know?

To change the text for your whole app, pass messages to KvirnProvider instead.

Dates in separate boxes for day, month and year

A resident reports the days they were away, which they know from memory. Give each end a DateInput instead of a masked field, and put the group of each end in its own Fieldset with a legend. Put the one trigger after the end’s boxes. The picker works the same with either.

Dates you were away from home (optional)
First day away (optional)

Focus moves to the next box when a box is full.

For example 27 10 2026

Last day away (optional)

Focus moves to the next box when a box is full.

For example 27 10 2026

Choose the dates

A booking of at least two days, in a season

Set minimumDays for the fewest days, counting both ends, and maximum for the last day that can be chosen. A day that would make the range too short says so in its name (“fewer than 2 days”). Write both limits in the group’s help text.

Dates you want to hire the hall (optional)

For example 27/10/2026

For example 27/10/2026

Hire it for at least 2 days, between 14 October and 31 December 2026.

Choose the dates

Props in this example:

Warning: Don't forget

A typed range can still break a limit, and the picker doesn’t check it. Check it when the form is sent, as in the stay with a longest length (3.3.1 Error Identification).

Accessibility#

What it does for you#

  • APG pattern: Date Picker Dialog (a modal dialog around a grid), after two typed fields. APG has no range pattern: a range is two ordinary selections. The grid is described on the Calendar page (range mode), the dialog on the Dialog page, and the single-date sibling on the DatePicker page.
  • Deviations: none new, and no key is added. From the APG example: no OK and Cancel buttons (the second press closes; Close and Escape cancel); the month is announced by Announcer on a button press; Tab leaves the modal to the browser's own UI before wrapping (a deviation from the APG Dialog pattern, approved).
  • Native elements used: <button type="button"> (trigger and Close), a native <dialog> shown with showModal(), <h2> (title), and the Calendar's <table role="grid"> (two of them on a wide screen).

DateRangePicker is an add-on to two typed fields (a From and a To, each one masks.date() TextInput, or each a DateInput): typing always works, and the dialog is the slower path for keyboard and screen reader users. It is controlled only: it keeps no range of its own. The fields' range goes in as value ({ start, end }, each as year-month-day such as 2026-10-15, or '' for an empty end) and the chosen range comes out once, through onValueChange, for the consumer to write into both fields. The one masked field per end is the default composition; the three-box DateInput per end is supported with every feature. There is no defaultOpen: a picker never starts open.

PartElement / roleARIANotes
Rootnone (renders no element)noneOwns the open state, the draft range and the Dialog's context
Trigger<button type="button"> → buttonname = its visible text dateRangePicker.trigger; aria-haspopup="dialog"; aria-expanded true/falseOne, after both fields. The calendar icon is decorative (aria-hidden). Classes kv-button kv-date-range-picker-trigger; data-open while open
Popupnative <dialog> → dialogaria-modal="true" while open; aria-labelledby → TitleClass kv-dialog kv-date-range-picker-popup. Top layer; the page behind is inert
Title<h2> (tabindex="-1")nonedateRangePicker.title, replaceable with the question. Names the dialog
Close<button> icon buttonname = dialog.closeThe Dialog's own Close
Calendardiv.kv-calendar with the Calendar's partsas on the Calendar page, range mode: aria-multiselectable, aria-selected on the rangeMounted only while the dialog is open. Two grids on a wide screen, one on a narrow one. The step line (choose the start, choose the end) is in the range hint

Rules the automated tests check:

  • Opens on the typed start, else the typed end, else today, kept inside minimum–maximum. The step follows: a start only gives the end step; an end only gives the start step; both give a finished range (a press starts a new one); an end before the start shows as the start alone and is never rewritten. A partial or impossible text counts as no date and gives no error from the picker: the form validates.
  • Press 1 sets the draft start (fields unchanged, dialog open, "Start date … Choose the end date." announced in the dialog). Press 2 on a possible end closes at once, calls onValueChange once with the finished range, and the consumer writes both fields. A day that can't be the end (before the start, too short, too long, past an unavailable day) becomes the new start and says so (restart, not swap). An unavailable day does nothing.
  • Escape and Close drop the draft: both fields stay as they were, onValueChange is not called, and the next opening starts from the typed range.
  • Dev warnings (once): an end that is not in the form year-month-day; a part used outside a DateRangePicker.Root.

What you need to do#

  • Keep the typed fields. DateRangePicker never replaces them: typing always works, and each keeps autocomplete where it applies (1.3.5 Identify Input Purpose (AA)) and avoids dragging (2.5.7 Dragging Movements (AA)). Put both in a group Fieldset with a legend ("Dates of your stay"), give each its own label and example, and put the error on the To field (Field.ErrorMessage, or the Fieldset's).
  • Bridge both ends. value={{ start: maskedDateToIsoDate(from, locale), end: maskedDateToIsoDate(to, locale) }} (or dateInputValueToIsoDate per DateInput) in, and onValueChange={(range) => …} out, one isoDateToMaskedDate or isoDateToDateInputValue per end. Validate the order and the span yourself (the picker never produces a reversed or over-long range, but a typed one can be).
  • Say the limits. Pass minimum, maximum, minimumDays and maximumDays and put them in the help text too (3.3.2 Labels or Instructions (A)); a booking says nights (14 nights is maximumDays={15}).
  • Name the task. Replace the title with the question ("Choose the dates of your stay").
  • Put the one trigger after both fields. The Popup can sit in a page <form>: none of its buttons submits it.
  • Not for a range far from today (type it), nor when many days are unavailable (use radio buttons).
  • Everything in the Calendar and Dialog contracts applies.

Warning: Don't forget

Write the limits in the group’s help text too. The dialog shows them only once it is open (3.3.2 Labels or Instructions).

Visual and modes#

  • Focus indicator: the trigger and Close are Buttons and have the Button's focus ring; the grids' is in the Calendar contract.
  • Target size: the trigger is a Button, and the day cells are larger than the 24 by 24 CSS pixel minimum of 2.5.8 Target Size (Minimum) (AA), also on a narrow screen.
  • Layout: the fields and the trigger sit in kv-date-range-row, which wraps: side by side on a wide screen, stacked on a narrow one, the trigger last (at 320px or 200% text it wraps below the To field). On a wide screen the popup is as wide as its calendar, with two months; on a narrow screen it shows one month, and below that it is a sheet.
  • Forced colours: in forced colours (the user's own system colours) it behaves as the Dialog and the Calendar do, and the trigger is a Button.
  • Reduced motion: the picker adds no motion of its own; the Dialog's opening motion is the only motion.

Focus management#

  • Without a provider timeZone, "today" is the UTC date on first paint only. The Calendars mount in the popup on every open, so a popup that opens after mount starts on the browser's date (no switch) and initial focus lands on the cell marked aria-current="date".
  • Initial focus: the day with the Tab stop (the typed start, else the typed end, else today, kept inside the range), through the Dialog's initialFocusRef. Not the first month button.
  • Trap: yes, native modal (the page behind is inert). Tab leaves to the browser's UI before wrapping (the Dialog's approved deviation), so there is no keyboard trap (2.1.2 No Keyboard Trap (A)).
  • Restore to: the trigger, for the end, Escape and Close alike. If the trigger is gone, the first input in the trigger's nearest fieldset, group or field: with two masked fields in one row that is the From field; with a Fieldset per end it is the end's first box (the closer landing spot). Never body.
  • Never obscured by: nothing inside is sticky; the sheet scrolls (2.4.11 Focus Not Obscured (Minimum) (AA)).

Information: Did you know?

Without a timeZone on KvirnProvider, the first paint uses today’s date in UTC, and a dialog that opens later starts on the browser’s date. Pass timeZone so the server and the browser agree on the day.

WCAG success criteria#

  • 2.1.1 Keyboard (A), 2.1.2 No Keyboard Trap (A), 2.4.3 Focus Order (A): every row above; focus lands on the day and returns to the trigger.
  • 1.3.1 Info and Relationships (A), 4.1.2 Name, Role, Value (A): roles, names and states of the trigger, dialog and grids (checked by tests and axe).
  • 3.3.2 Labels or Instructions (A): the range hint and the fields' help text. 3.3.7 Redundant Entry (A): the typed range is the starting point. 2.5.7 Dragging Movements (AA): no dragging is needed.
  • 4.1.3 Status Messages (AA): the step and the finished range, the latter after the dialog has closed.
  • 3.1.2 Language of Parts (AA): the Calendar's lang when the browser has no data for the locale.
  • 2.5.3 Label in Name (A): the trigger is named by its visible text.
  • 2.4.7 Focus Visible (AA), 2.4.11 Focus Not Obscured (Minimum) (AA): the trigger and Close are Buttons with the Button's ring, the grids' ring is the Calendar's, and nothing inside is sticky. The ring is checked by eye.
  • 1.4.3 Contrast (Minimum) (AA), 1.4.11 Non-text Contrast (AA): the dialog and the grids use the Dialog's and the Calendar's colours, measured by the theme's contrast check, and axe finds no violation in any story, closed or open.
  • 1.4.10 Reflow (AA): the reflow sweep checks every story at 320 CSS pixels for horizontal overflow.
  • 1.4.12 Text Spacing (AA): the text-spacing sweep applies the wider spacing to every story and fails on a box that clips text.
  • 2.5.8 Target Size (Minimum) (AA): the size of the sheet and the day cells is checked by eye.

Keyboard#

Focus
native for the fields, the trigger and the dialog's buttons; roving tabindex in the grids (Calendar), one Tab stop across both months
Selection follows focus
no (Enter or Space selects)
Arrows wrap
no (they cross months and the two grids, as in Calendar)
Shortcuts
none

The grids' own keys (arrows, Home, End, Page keys, month buttons, the two-month crossings and the press outcomes) are on the Calendar page and are proved by the Calendar's tests; only what the dialog adds is listed here. A key with Control, Alt or Meta is never taken.

KeyWhereWhat happens
TabFrom fieldMoves to the To field
Test: date-range-picker.test.tsx › keyboard › Tab moves from the From field to the To field and on to the trigger
TabTo fieldMoves to the one trigger, after both fields
Test: date-range-picker.test.tsx › keyboard › Tab moves from the From field to the To field and on to the trigger
Shift+TabtriggerMoves back to the To field, then the From field
Test: date-range-picker.test.tsx › keyboard › Shift+Tab moves from the trigger back to the To field and the From field
Tab / Shift+Tabopen dialogClose, the month buttons, then both grids as one stop; Shift+Tab goes back; Tab leaves the dialog to the browser's own controls, such as the address bar, before it goes round again
Test: date-range-picker.test.tsx › keyboard › Shift+Tab from the day goes through the month buttons to Close, and Tab goes back
EntertriggerOpens the dialog; focus on the start, else the end, else today (both fields empty)
Test: date-range-picker.test.tsx › keyboard › Enter on the trigger opens the dialog with focus on today when both fields are empty
SpacetriggerOpens the dialog, as Enter
Test: date-range-picker.test.tsx › keyboard › Space on the trigger opens the dialog
Entertrigger, a typed rangeOpens on the typed start, the typed range selected
Test: date-range-picker.test.tsx › keyboard › the dialog opens on the typed start, with the whole typed range selected
Entertrigger, a start onlyOpens on the start at the end step
Test: date-range-picker.test.tsx › keyboard › with only a start typed the dialog opens on it at the end step
Entertrigger, an end onlyOpens on the end at the start step
Test: date-range-picker.test.tsx › keyboard › with only an end typed the dialog opens on it at the start step
Entertrigger, an end before the startOpens on the start at the end step; nothing is rewritten
Test: date-range-picker.test.tsx › keyboard › an end typed before the start opens on the start at the end step, nothing rewritten
Entertrigger, partial textCounts as no date: opens on today
Test: date-range-picker.test.tsx › keyboard › partial text counts as no date: the dialog opens on today
Control, Alt or Meta + EntertriggerNot taken
Test: date-range-picker.test.tsx › keyboard › a key with Control, Alt or Meta on the trigger does not open the dialog
ArrowRightdayMoves to the next day inside the dialog (the rest as Calendar)
Test: date-range-picker.test.tsx › keyboard › an arrow key moves between days inside the dialog
Enteravailable day, start stepSets the start; the dialog stays open; the step line says to choose the end
Test: date-range-picker.test.tsx › keyboard › Enter on a day sets the start: the dialog stays open, the fields are unchanged and the step line says to choose the end
Enterpossible endChooses it: closes, fills both fields, focus to the trigger
Test: date-range-picker.test.tsx › keyboard › Enter on the end closes the dialog, fills both fields and returns focus to the trigger
Spacepossible endThe same as Enter
Test: date-range-picker.test.tsx › keyboard › Space on the end chooses it and closes the dialog
Enterstart again, end stepA one-day range; closes
Test: date-range-picker.test.tsx › keyboard › Enter on the start again makes a one-day range and closes
Enterday before the startBecomes the new start, announced; the dialog stays open
Test: date-range-picker.test.tsx › keyboard › a day before the start restarts: it becomes the new start and the dialog stays open
Enterday that makes the range too longBecomes the new start, announced; its name says why
Test: date-range-picker.test.tsx › keyboard › a day that makes the range too long restarts, says so in its name, and the dialog stays open
Enter / Spaceunavailable dayNothing; the dialog stays open
Test: date-range-picker.test.tsx › keyboard › Enter on an unavailable day does nothing and the dialog stays open
Escapeopen dialog, a start pressedCloses; the half-chosen range is dropped; both fields unchanged; focus to the trigger
Test: date-range-picker.test.tsx › keyboard › Escape after the first press discards the half-chosen range: both fields stay as they were and focus returns to the trigger
EscapereopenedOpens on the typed range again, not on the dropped start
Test: date-range-picker.test.tsx › keyboard › the dialog reopens on the typed range, not on the half-chosen one dropped by Escape
Enter / SpaceCloseCloses; the draft is dropped; focus to the trigger
Test: date-range-picker.test.tsx › keyboard › the Close button discards the half-chosen range and returns focus to the trigger

A click on a day presses it the same way. With the trigger gone, focus goes to the first box of the group around it.

Announcements#

DateRangePicker tells screen reader users about these changes without moving focus. Each message waits until the screen reader is quiet (polite) or interrupts it (assertive).

WhenWhat it saysMessage keyPoliteness
The start is pressedcalendar.rangeChooseEndPolite
A day restarts the rangecalendar.rangeChooseEndPolite
The end is chosencalendar.rangeSelectedPolite
A month button is pressedcalendar.visibleMonthsPolite

The text in all five languages

Change the text#

For your whole app, pass messages to KvirnProvider. For one DateRangePicker, pass its messages prop.

<KvirnProvider messages={{ calendar: { rangeChooseEnd: '…' } }}>

Warning: Don't forget

Announcements need a KvirnProvider around your app, outside any <form>, or an Announcer of your own. Without one nothing is announced, and a development warning says so.

What a screen reader reads#

State or actionRead aloudPolitenessTest
The fields and the triggerFrom, To, then button, Välj datumen (Choose the dates), not expandednonedate-range-picker.test.tsx › read aloud › reads the From field, the To field, then the trigger as a button with a popup that is not expanded
Open dialog, typed rangedialog, Välj perioden (Choose the period) → heading → grid, oktober 2026 (October 2026) → grid, november 2026 (November 2026) → the start day, read with startdatum (start date) and selected, and the end day, read with slutdatum (end date) and selectednonedate-range-picker.test.tsx › read aloud › reads the open dialog by its title, then both grids and the typed range as selected
The start is pressedpolite: Startdatum fredag 16 oktober 2026. Välj slutdatum. (Start date Friday 16 October 2026. Choose the end date.)politedate-range-picker.test.tsx › read aloud › says "Startdatum … Välj slutdatum." as a polite announcement when the start is pressed
The end is chosenafter close: polite: fredag 16 oktober 2026 till fredag 23 oktober 2026 valda, 8 dagar (Friday 16 October 2026 to Friday 23 October 2026 selected, 8 days)politedate-range-picker.test.tsx › read aloud › says "{start} till {end} valda, {length}" as a polite announcement when the end is chosen
Closed with Escape or Closenothingnonedate-range-picker.test.tsx › announcements › closing with Escape announces nothing and … › closing with Close announces nothing

API reference#

import { DateRangePicker, useDateRangePicker } from '@kvirn-ui/react'

DateRangePicker.Root

Renders No element. It owns the open state, the draft range (the days pressed so far) and the limits, and gives the Dialog its context. Inside it, put the group Fieldset with the From and To fields and one DateRangePicker.Trigger after both, then DateRangePicker.Popup. Put the fields and the trigger in a div with the class kv-date-range-row: it wraps on a narrow screen. Each end can be a masked TextInput or a DateInput. The default theme is described on Theming.

PropTypeDefaultDescription
valueDateRange{ start: "", end: "" }The range the two fields hold, { start, end } as YYYY-MM-DD, "" for a date that is empty or partial. Build each end with dateInputValueToIsoDate or maskedDateToIsoDate. DateRangePicker is controlled only: it never writes the fields itself.
onValueChange(range: DateRange) => void–Called once, with the finished range, when the end is chosen. Write both ends into your fields, then. Escape and Close never call it.
openboolean–Controlled: whether the dialog is open. Pair it with onOpenChange. Without it the picker is uncontrolled and starts closed.
onOpenChange(open: boolean, details: DateRangePickerChangeDetails) => void–Called when the dialog opens or closes. details.reason is "trigger-press", "close-press", "escape" or "native-close" (the Dialog’s reasons), or "select" when the end was chosen.
minimumIsoDate–The first day that can be chosen, as YYYY-MM-DD.
maximumIsoDate–The last day that can be chosen, as YYYY-MM-DD.
minimumDaysnumber–The fewest days, counting both ends (a one-day range is 1).
maximumDaysnumber–The most days, counting both ends. A booking of 14 nights is 15.
allowUnavailableInRangebooleanfalseLets a range pass over an unavailable day. By default it blocks.
isDateUnavailable(date: IsoDate) => boolean–A day inside the range that can’t be chosen. It stays focusable, struck through.
getDateDescription(date: IsoDate) => string | undefined–Words added to a day’s name, such as why it is unavailable.
weekStartWeekStartThe provider’sThe first day of the week, 1 (Monday) to 7 (Sunday). Else the provider’s, the locale’s, Monday.
weekNumbersbooleanfalseISO week numbers, with a Monday start only.
todayIsoDateThe clockToday as YYYY-MM-DD, for tests and examples. Else the clock, read each time the dialog opens.
messagesPartial<KvirnMessages['dateRangePicker']>–Replaces the trigger’s text and the dialog’s title for this picker.
calendarMessagesPartial<KvirnMessages['calendar']>–Replaces the Calendar’s strings for this picker, and "{start} to {end} selected", said on the page after the dialog has closed.

DateRangePicker.Trigger

Renders A <button type="button"> named “Choose dates” (dateRangePicker.trigger) with a decorative calendar icon. It takes every attribute of a <button> and passes ref to it. If you pass children, the visible text must stay its name.

Class or attributeValuesMeaning
kv-dialog-trigger kv-button kv-date-range-picker-triggeralwaysThe part classes. It looks like a Button.
aria-haspopup"dialog"The button opens a dialog.
aria-expanded"true" or "false"Whether the dialog is open.
data-openpresent or absentThe dialog is open.

DateRangePicker.Popup

Renders A modal <dialog>, a Dialog popup. With no children it holds the Title, a Close button and the range Calendar, which is mounted only while the dialog is open. It takes every attribute of a <dialog> and passes ref to it.

Class or attributeValuesMeaning
kv-dialog kv-date-range-picker-popupalwaysThe part classes. The default theme styles them.
aria-modal"true" while openThe page behind is inert.
aria-labelledbythe Title’s idNames the dialog. Give it a title.
data-openpresent or absentThe dialog is open.

DateRangePicker.Title

Renders An <h2> that names the dialog, “Choose the dates” (dateRangePicker.title). It takes every attribute of a heading and passes ref to it.

PropTypeDefaultDescription
as'h2' | 'h3' | 'h4' | 'h5' | 'h6''h2'The element, so the title has the level it needs in the page’s outline.
Class or attributeValuesMeaning
kv-dialog-titlealwaysThe part class.

DateRangePicker.Calendar

Renders A Calendar.Root in range mode with the picker’s draft and limits set, and the month buttons, both headings, the range hint and both grids inside it (the second month shows on screens 64rem wide or more). It takes the attributes of a <div>, not the Calendar’s options: those come from the picker. Give it children to compose your own.

useDateRangePicker

Takes the same options as DateRangePicker.Root. Render the Calendar only while isOpen: it reads the range when it mounts.

Options

PropTypeDefaultDescription
valueDateRange{ start: "", end: "" }The range the two fields hold, { start, end } as YYYY-MM-DD, "" for a date that is empty or partial. Build each end with dateInputValueToIsoDate or maskedDateToIsoDate. DateRangePicker is controlled only: it never writes the fields itself.
onValueChange(range: DateRange) => void–Called once, with the finished range, when the end is chosen. Write both ends into your fields, then. Escape and Close never call it.
openboolean–Controlled: whether the dialog is open. Pair it with onOpenChange. Without it the picker is uncontrolled and starts closed.
onOpenChange(open: boolean, details: DateRangePickerChangeDetails) => void–Called when the dialog opens or closes. details.reason is "trigger-press", "close-press", "escape" or "native-close" (the Dialog’s reasons), or "select" when the end was chosen.
minimumIsoDate–The first day that can be chosen, as YYYY-MM-DD.
maximumIsoDate–The last day that can be chosen, as YYYY-MM-DD.
minimumDaysnumber–The fewest days, counting both ends (a one-day range is 1).
maximumDaysnumber–The most days, counting both ends. A booking of 14 nights is 15.
allowUnavailableInRangebooleanfalseLets a range pass over an unavailable day. By default it blocks.
isDateUnavailable(date: IsoDate) => boolean–A day inside the range that can’t be chosen. It stays focusable, struck through.
getDateDescription(date: IsoDate) => string | undefined–Words added to a day’s name, such as why it is unavailable.
weekStartWeekStartThe provider’sThe first day of the week, 1 (Monday) to 7 (Sunday). Else the provider’s, the locale’s, Monday.
weekNumbersbooleanfalseISO week numbers, with a Monday start only.
todayIsoDateThe clockToday as YYYY-MM-DD, for tests and examples. Else the clock, read each time the dialog opens.
messagesPartial<KvirnMessages['dateRangePicker']>–Replaces the trigger’s text and the dialog’s title for this picker.
calendarMessagesPartial<KvirnMessages['calendar']>–Replaces the Calendar’s strings for this picker, and "{start} to {end} selected", said on the page after the dialog has closed.

Result

PropTypeDefaultDescription
isOpenboolean–Whether the dialog is open.
triggerPropsDateRangePickerTriggerPartProps–Spread on the <button> that opens the picker.
popupPropsDateRangePickerPopupPartProps–Spread on the <dialog>. Name it with a title.
titlePropsDialogTitlePartProps–Spread on the title element. Call registerTitle from an effect in it.
closePropsDialogClosePartProps–Spread on the button inside the popup that closes it.
registerTitle() => () => void–Call it from an effect in your title element, as for a Dialog.
calendarPropsDateRangePickerCalendarOptions–The Calendar’s options (mode "range", the draft value, the limits, two visible months): spread them on Calendar.Root while the dialog is open. Its own "selected" messages are off, because the page says the range after the dialog has closed.
triggerTextstring–"Choose dates": the trigger’s visible text.
titleTextstring–"Choose the dates": the default title.
dialogUseDialogResult & { isShown: boolean }–The Dialog behind the picker, for DateRangePicker.Root.

Strings

These are the default texts in @kvirn-ui/i18n.

For your whole app, pass messages to KvirnProvider. For one DateRangePicker, pass its messages prop.

dateRangePicker.trigger

The visible text and name of the trigger.

LanguageDefault text
SvenskaVälj datumen
SuomiValitse päivät
Norsk bokmålVelg datoer
Norsk nynorskVel datoar
EnglishChoose dates

dateRangePicker.title

The default title of the dialog.

LanguageDefault text
SvenskaVälj perioden
SuomiValitse päivämäärät
Norsk bokmålVelg datoene
Norsk nynorskVel datoane
EnglishChoose the dates

Known issues#

  • Screen reader users: a screen reader may not say the finished range when focus lands on the trigger. Check with your users.
  • Screen reader users: aria-selected on every day between the ends may be noisy. Test it with your own screen reader users.
  • Children you pass to DateRangePicker.Popup stay mounted while the dialog is closed (the default Calendar does not).

Information: Did you know?

If an issue here affects your service, list it in your accessibility statement with its workaround.

Testing#

The automated tests prove the keyboard behaviour, the names and states, that axe finds no violations in every story and theme, and, for the components they cover, that the stories hold up in forced colours, reduced motion, text spacing and a 320 pixel width. An Automated row passes on these tests alone. A Core or Release row passes only when an automated agent check and a person on the real assistive technology have both checked it. "agent-verified" means automated tests in the repository (with a virtual screen reader for the screen reader rows), not the real assistive technology.

AT + browser + OSAgent checkHuman checkResultNotes
Automated (re-runnable tests)
axe, WCAG 2.2 A and AA, every story, 4 themespassn/apassdate-range-picker.stories.tsx, every story, 4 themes
Markup and ARIA (roles, names, ids, states)passn/apassdate-range-picker.test.tsx (axe and role, name and state): there is one trigger after both fields: a button named by its visible text, with a hidden icon, aria-haspopup and aria-expanded false
Keyboard contract rows (Vitest browser)passn/apass23 rows, each names a test in date-range-picker.test.tsx
Focus order and managementpassn/apassdate-range-picker.test.tsx: Enter on the trigger opens the dialog with focus on today when both fields are empty
Display modes (forced colours, 320px reflow, text spacing, reduced motion)passn/apassthe four sweep projects (storybook-forced-colors, -reduced-motion, -reflow, -text-spacing), run in CI
Core (required for beta)
NVDA + Chrome + Windowspendingpendingpending
VoiceOver + Safari + iOSpendingpendingpending
Release (before 1.0 and each minor)
JAWS + Chrome + Windowspendingpendingpending
TalkBack + Chrome + Androidpendingpendingpending
VoiceOver + Safari + macOSpendingpendingpending

What to check#

  • Tab through From, To and "Choose dates". Press Enter: the dialog is read by its title, and focus is on the typed start (or today).
  • Press Enter on a day: the dialog stays open and "Start date …. Choose the end date." is read.
  • Press Enter on a later day: the dialog closes, both fields fill, focus is on the button, and the range and its length are read.
  • Press Enter on a day before the start: it becomes the new start and this is announced.
  • Start a range, then press Escape: both fields are unchanged and focus is on the button.
  • With a longest stay set, a day too far away says so in its name.