Toggle Group
catnip-toggle-group is a role="radiogroup" of role="radio" segments with arrow-key navigation built in. You provide the group label and a text label for every option.
Keyboard
| Key | Behaviour |
|---|---|
| Arrow keys | Move the selection. |
| Home / End | Jump to the first / last enabled segment. |
| Space / Enter | Select the focused segment. |
Screen readers
| Part | Semantics |
|---|---|
| Group | role="radiogroup" with aria-labelledby pointing at the field label when visible. |
| Segment | A role="radio" button with aria-checked. |
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 focused option shows a system-colour outline.
- The selected segment's label is semibold and the others are regular, so the selection isn't shown by colour alone. In Windows contrast themes it's filled with the system selection colours, since every segment gets the same border there.
- Segment labels wrap, breaking long words if they must, so nothing is cut off in a narrow group or with larger text spacing.
What you own
- Label: Set
label(or thelabelslot). Withhide-label, settoggle-group-aria-labelto name the group. - Icon options: Keep a text
labelfor every icon-bearing option; the icon is decorative and does not replace the accessible option name. - 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.
- Outside label or description: A
<label for>orcatnip-field-label html-forthat points at thecatnip-toggle-groupelement'sidnames the inner control when the field has no label of its own, and clicking it focuses the selected option, or the first one. 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.
WCAG 2.2 AA
| Criterion | The component | You |
|---|---|---|
| 1.3.1 Info and relationships, 4.1.2 Name, role, value | A named radiogroup of radio segments | Short labels; a label for icon-only options |
| 1.4.1 Use of color, 1.4.11 Non-text contrast | The selected segment's label is semibold, so the selection isn't shown by fill alone; system selection colours in Windows contrast themes | Don't override component colours |
| 1.4.10 Reflow, 1.4.12 Text spacing | Labels wrap at 320 px and with larger text spacing | Keep labels short and check them at 320 px |
| 2.1.1 Keyboard | One Tab stop; arrow keys, Home and End | — |
| 2.4.7 Focus visible | A focus ring in every state, read-only and Windows contrast themes included | Don't override focus styles |
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.