Skip to content

Dropdown ​

catnip-dropdown is a combobox trigger with a list panel rendered right after the field. Keyboard navigation, typeahead, focus handling, and the ARIA wiring between the trigger, the search field and the list are built in. You provide the label and validation messages, and, with a custom trigger slot, a focusable, named control.

Keyboard ​

Trigger ​

Tab moves focus to the trigger. Focusing the trigger never opens the panel; a click or the keys below do.

KeyBehaviour
Enter / Space / Arrow Down (also Alt + Arrow Down)Opens the panel on the selected option, or the first one.
Arrow UpOpens the panel on the selected option, or the last one.
Home / EndOpens the panel on the first / last option.
A letter or digitOpens the panel on the first option that starts with it; with filterable, starts the search with it.

These follow the APG select-only combobox pattern.

Open panel ​

When the panel is open and focus is on the trigger (without filterable):

KeyBehaviour
Arrow Up / Arrow Down, Home / EndNavigate the options.
TypingTypeahead.
Enter / SpaceSelect the active option.
EscapeCloses the panel; focus returns to the trigger (or the first focusable child in a custom trigger slot). Only the dropdown that has focus closes.
Alt + Arrow UpCloses the panel and keeps the selection.
TabMoves on to the next control (or into the Select all checkbox or listFooter actions) and closes the panel when focus leaves the dropdown.

On open, the first selected visible option is highlighted when possible. Picking an option in a single-select dropdown closes the panel and returns focus to the trigger. A press outside, or focus moving to another control, closes the panel and leaves focus where it went.

Chips ​

With display-mode="chips", the combobox is one Tab stop and each chip's remove button is its own, followed by Show more and the clear button. Enter or Space on a remove button removes the chip without opening the list. After a removal, focus moves to the next chip's remove button, else the previous one, else the trigger, and a polite live region announces "{chip} removed" (dropdown.chipRemoved).

Select all ​

With select-all, a Select all checkbox sits above the list, after the search field. Reach it with Tab from the trigger or the search field and toggle it with Space. The arrow keys move through the options only.

Custom trigger ​

With a trigger slot, Enter, Space or Arrow Down on your control opens the list and moves focus to the selected option, or the first one; the arrow keys, Home, End and typeahead move focus through the options. Escape and a pick return focus to your control.

Filter field ​

With filterable, focus moves to the search field on open.

KeyBehaviour
Arrow Up / Arrow Down, Home / End, Enter, EscapeWork on the list, as in the table above. Escape returns focus to the trigger.
TabMoves on to the next control (or into listFooter actions) and closes the panel when focus leaves the dropdown.
Space and ordinary lettersStay in the filter input, so you can type spaces in the filter.

Screen readers ​

PartSemantics
TriggerThe default trigger is a combobox with aria-haspopup="listbox" and aria-expanded, plus aria-controls and aria-activedescendant while open. The panel renders inside the component, so both resolve. intent="danger" sets aria-invalid on the trigger.
PanelRendered right after the field, so reading order and Tab order follow it, and shown in the top layer, so it isn't clipped by overflow: hidden and works inside a modal <dialog>.
ListboxNamed by the field label. Contains options only.
ValueThe combobox's value is the selected label, "{count} selected", or with chips the selected labels in one text ("Norway, Sweden"); chips, Show more and the clear button sit beside the combobox, not inside it. With nothing selected, the placeholder is read as part of the description, not as the value.
LabelA click on the field label focuses the trigger, since a combobox element can't be the target of a label's for.
Search fieldWith filterable, a role="combobox" above the listbox with aria-autocomplete="list", aria-expanded, aria-controls, and aria-activedescendant for the active option.
No resultsShown after the listbox and announced through a polite live region (dropdown.noResults).

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 ​

  • In Windows contrast themes, the trigger's border and focus ring show in system colours.
  • The clear button and the chip remove buttons are 24 × 24 px targets at every size (WCAG 2.5.8), with the same visible size as before.
  • Long chip labels wrap inside the field instead of running past it, also at 320 px.
  • A read-only dropdown stays in the Tab order with aria-readonly and the same focus ring as an editable one. It doesn't open, and arrow keys, Space and Enter do nothing.

What you own ​

  • Label: Set label (or the label slot). Without a visible label, set dropdown-aria-label on the trigger.
  • Validation messages: Set intent="danger" and supporting-text together (see Validation).
  • Custom trigger: With slot="trigger", put the slot on the focusable control itself (for example <button type="button">) and give it an accessible name. The dropdown sets aria-haspopup and aria-expanded on it. It doesn't set aria-controls: the list is inside the component's shadow root, which an ID on your light-DOM control can't reach.
  • Errors on submit: Supporting text isn't a live region, so a message that appears later isn't announced by itself. On submit, move focus to the first invalid field or to an error summary.
  • Option content: Put only text and decorative content (icons, flags, badges) in <catnip-dropdown-option> slots. The list shows a copy inside an option, so links or buttons there don't work and would be nested in the option; IDs in it are removed from the copy.
  • Outside label or description: A <label for> or catnip-field-label html-for that points at the catnip-dropdown element's id names the inner control when the field has no label of its own, and clicking it focuses the combobox. 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.
  • Autofill: The combobox is a div, so it can't take an autocomplete purpose and browsers won't autofill it. For personal data such as a country or a title, where autofill matters (WCAG 1.3.5), use a native <select> with autocomplete and a catnip-field-label.

WCAG 2.2 AA ​

CriterionThe componentYou
1.3.1 Info and relationships, 4.1.2 Name, role, valueCombobox and listbox named by the label; the value reads the selected labels; the placeholder is a descriptionA label; only text and decorative content in option slots
1.3.5 Identify input purpose—A native <select> with autocomplete for personal data that browsers should autofill
2.1.1 Keyboard, 2.1.2 No keyboard trapAPG select-only combobox keys; Tab moves on and closes the list—
2.4.3 Focus orderThe list follows the field; focus returns after Escape or a pick and stays where you moved it otherwiseKeep source order matching visual order
2.4.7 Focus visibleA focus ring in every state, read-only and Windows contrast themes includedDon't override focus styles
2.5.8 Target sizeClear and chip remove buttons are 24 × 24 px—
4.1.3 Status messages“No results” and “{chip} removed” are announced politely—

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

Known issues ​

  • Autofill: the combobox is a div, so browsers don't autofill it. Use a native <select> for personal data (see What you own).

Catnip Design System by Signicat