Skip to content

Date Input ​

catnip-input-date is a combobox field with a calendar dialog. Keyboard support, screen-reader names and announcements, focus handling, and Windows contrast theme styles are built in. You provide the label, your own validation messages, and the reasons behind unavailable dates.

Keyboard ​

Field ​

KeyBehaviour
Arrow Down / Alt + Arrow DownOpens the panel and moves focus into it: the selected preset (or the first one), otherwise the active day.
EnterCommits the typed value and closes the panel; with Apply in the panel, works as Apply.
TabCloses the panel and moves on, like any combobox.
EscapeCloses the panel.

Focusing the field never opens the panel; a click opens it and keeps focus in the field. Each time the panel opens it shows the selected date (the range start, or today when nothing is selected), not the month browsed last time.

Panel ​

KeyBehaviour
Tab / Shift + TabMoves between the panel's controls; focus wraps inside the panel.
EscapeCloses the panel and returns focus to the field. With Apply, also discards the draft like Cancel.

The panel closes on Escape, Tab from the field, picking a date (single date without time), Apply, Cancel, or a click outside. Focus returns to the field after every close except a click outside. A visually hidden Close button (not in the Tab order) is added when the panel has no Cancel, so touch screen reader users can dismiss it.

Presets ​

KeyBehaviour
Arrow Up / Arrow DownPrevious / next preset.
Home / EndFirst / last preset.
Enter / SpacePick the focused preset.

The list has one Tab stop: the focused, otherwise selected, preset.

Calendar ​

KeyBehaviour
Arrow Left / RightMove active day backward / forward.
Arrow Up / DownMove active day by one week.
Home / EndMove to the start / end of the active week.
PageUp / PageDownMove to the previous / next month.
Shift + PageUp / Shift + PageDownMove to the same month in the previous / next year.
Enter / SpaceSelect active date.

Arrow keys stop at min and max. Unavailable days (disabled-dates, or past max-range-days while picking the end) can be focused and are announced as unavailable, but not selected. The calendar has one Tab stop, on the active day, even with two months shown.

The month/year header button opens a year grid. In range mode it also opens a month grid: years on the left and months on the right in the horizontal dual-month panel, or years above months in the vertical stack. Selecting a year updates the month grid; selecting a month returns to the day calendars. Single-date mode still uses the year grid only. In the year grid, arrow keys move between years, PageUp / PageDown move between year ranges, and Enter / Space selects the active year. In the month grid, arrows move between months and Enter / Space selects the active month.

Screen readers ​

PartSemantics
Field<input role="combobox"> with aria-haspopup="dialog", aria-expanded, aria-autocomplete="none", and aria-controls while open. Described by its expected format and the supporting text; intent="danger" sets aria-invalid="true".
Panelrole="dialog" named "{label}, Choose date" (or "Choose dates" in range mode). aria-modal="true" only while focus is inside. Rendered right after the field, so reading order and Tab order follow it; shown in the top layer.
Month<table role="grid"> named by month and year; weekday column headers carry the full weekday name; each day is a button in a role="gridcell".
Day namesFull date, then as applicable: "today", "unavailable", "selected", "start of selected range", "end of selected range". Today also has aria-current="date".
Live regionPolite. Announces "Start date {date}. Choose an end date.", "Selected range: {range}", and the month shown after the previous / next buttons.
Preset fieldWhile a named preset is shown, its dates are added to the field's description; while the field has focus it shows the dates and describes "Preset: {name}".
Time fieldsLabeled text inputs (HH:mm), not native time pickers.

Override these strings through registerTranslate: inputDate.chooseDate, inputDate.chooseDates, inputDate.close, inputDate.presetDescription, and the shared calendar keys calendar.today ("today"), calendar.selected ("selected"), calendar.rangeStart ("start of selected range"), calendar.rangeEnd ("end of selected range"), calendar.unavailable ("unavailable"), calendar.startChosen ("Start date {date}. Choose an end date."), calendar.rangeSelected ("Selected range: {range}"), and calendar.dateSelected ("Selected: {date}"). Existing inputDate.* keys for navigation (for example inputDate.previousMonth) still take precedence over their calendar.* equivalents.

info renders a button after the label, named “More information about {label}” and described by the info text, which shows as a tooltip on hover and focus; Escape hides it. Content in label.action and label.suffix sits beside the <label>, not inside it, so it isn't part of the field's name.

Visual ​

  • The field shows a focus ring. In Windows contrast themes the field's border and focus ring, the time fields' focus, and the calendar's selection, range band, today, and focus all show in system colours.
  • The value stays on one line and scrolls inside the field when it doesn't fit; below 800px a horizontal range panel switches to the stacked layout.

What you own ​

  • Label: Set label (or the label slot), also with hide-label: the hidden label text still names the field. Use input-date-aria-label only when the accessible name should differ. Don't use display-format placeholders such as DD/MM/YYYY as the label.
  • From / To fields: In the vertical range-with-time panel, set start-label and end-label when the defaults don't fit.
  • Validation messages: When typed text can't be read, the field adds a format message (inputDate.invalidFormat) after your supporting-text. Every other rule is yours: set intent="danger" and say what's wrong and how to fix it in supporting-text. On submit, move focus to the first invalid field or an error summary.
  • Limits: When min, max, or max-range-days matter, state them in supporting-text.
  • Unavailable dates: Screen reader users hear that a day is unavailable, not why. Explain disabled-dates in nearby supporting text when the reason isn't obvious.
  • Custom trigger: With slot="trigger", put the slot on a focusable control and give it an accessible name. The field sets aria-haspopup="dialog" and aria-expanded on it.
  • Translations: Register translations for the strings above with registerTranslate, and set locale when the app locale differs from the browser's.
  • Outside label or description: A <label for> or catnip-field-label html-for that points at the catnip-input-date element's id names the inner control when the field has no label of its own, and clicking it focuses the field. IDs in aria-describedby (ariaDescribedby) are looked up in the page, or in the shadow root the element sits in, and read before the supporting text. Both are connected through element reflection; axe-core 4.11 doesn't read reflection yet and still reports label for an outside label.

WCAG 2.2 AA ​

CriterionThe componentYou
1.3.1 Info and relationships, 4.1.2 Name, role, valueCombobox field named by the label; dialog, grid, and listbox roles; day names include today, selection, range ends, and unavailability; aria-invalid with intent="danger"A label on every field
2.1.1 Keyboard, 2.1.2 No keyboard trapAPG date-grid keys; one Tab stop per calendar and preset list; Escape always closes the panelDon't capture keys globally while the field has focus
2.4.3 Focus orderThe panel follows the field in the DOM; focus returns to the field after Escape, a pick, Apply, and CancelKeep source order and visual order the same
2.4.7 Focus visibleVisible focus on the field and in the panel, including Windows contrast themesDon't override focus styles
3.2.1 On focusFocusing the field never opens the panelDon't submit or navigate when the value changes
3.3.1 Error identification, 3.3.3 Error suggestionUnreadable typed text stays in the field and is flagged with a format messageMessages for your own rules, and focus on the first invalid field on submit
3.3.2 Labels or instructionsThe expected format is part of the field's descriptionState limits such as min, max, and max-range-days
4.1.3 Status messagesPolite announcements for the range start, the completed range, month changes, and the format messageAnnounce results that depend on the date yourself, for example availability loaded from a server

This table says who handles what. It isn't a conformance claim: WCAG conformance is claimed for a page or a process.

Known issues ​

None known.

Catnip Design System by Signicat