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.
| Key | Behaviour |
|---|---|
| Enter / Space / Arrow Down (also Alt + Arrow Down) | Opens the panel on the selected option, or the first one. |
| Arrow Up | Opens the panel on the selected option, or the last one. |
| Home / End | Opens the panel on the first / last option. |
| A letter or digit | Opens 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):
| Key | Behaviour |
|---|---|
| Arrow Up / Arrow Down, Home / End | Navigate the options. |
| Typing | Typeahead. |
| Enter / Space | Select the active option. |
| Escape | Closes 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 Up | Closes the panel and keeps the selection. |
| Tab | Moves 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.
| Key | Behaviour |
|---|---|
| Arrow Up / Arrow Down, Home / End, Enter, Escape | Work on the list, as in the table above. Escape returns focus to the trigger. |
| Tab | Moves on to the next control (or into listFooter actions) and closes the panel when focus leaves the dropdown. |
| Space and ordinary letters | Stay in the filter input, so you can type spaces in the filter. |
Screen readers
| Part | Semantics |
|---|---|
| Trigger | The 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. |
| Panel | Rendered 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>. |
| Listbox | Named by the field label. Contains options only. |
| Value | The 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. |
| Label | A click on the field label focuses the trigger, since a combobox element can't be the target of a label's for. |
| Search field | With filterable, a role="combobox" above the listbox with aria-autocomplete="list", aria-expanded, aria-controls, and aria-activedescendant for the active option. |
| No results | Shown 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-readonlyand 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 thelabelslot). Without a visible label, setdropdown-aria-labelon the trigger. - Validation messages: Set
intent="danger"andsupporting-texttogether (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 setsaria-haspopupandaria-expandedon it. It doesn't setaria-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>orcatnip-field-label html-forthat points at thecatnip-dropdownelement'sidnames the inner control when the field has no label of its own, and clicking it focuses the combobox. IDs inaria-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 reportslabelfor an outside label. - Autofill: The combobox is a
div, so it can't take anautocompletepurpose 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>withautocompleteand acatnip-field-label.
WCAG 2.2 AA
| Criterion | The component | You |
|---|---|---|
| 1.3.1 Info and relationships, 4.1.2 Name, role, value | Combobox and listbox named by the label; the value reads the selected labels; the placeholder is a description | A 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 trap | APG select-only combobox keys; Tab moves on and closes the list | — |
| 2.4.3 Focus order | The list follows the field; focus returns after Escape or a pick and stays where you moved it otherwise | Keep source order matching visual order |
| 2.4.7 Focus visible | A focus ring in every state, read-only and Windows contrast themes included | Don't override focus styles |
| 2.5.8 Target size | Clear 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).