Radio Group
catnip-radio-group is a role="radiogroup" field whose rows are native radios, and it behaves like a native radio group from the keyboard. You provide the group label and validation messages.
Keyboard
Keyboard navigation behaves exactly like a native radio group:
| Key | Behaviour |
|---|---|
| Arrow keys | Change the selection. |
| Tab | Focuses the checked option. |
Screen readers
| Part | Semantics |
|---|---|
| Group | role="radiogroup" with aria-labelledby pointing at the field label when visible. |
| Row | A native radio inside an internal catnip-radio (see Radio — Accessibility). Row intent="danger" sets aria-invalid on that radio's native input. |
- With
required, the radiogroup setsaria-required="true", so the group is announced as required.
With intent="danger", the radiogroup has aria-invalid="true", and its supporting text also describes every radio, because screen readers don't all read a group's description when focus moves into it.
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
- With
readonly, the radiogroup getsaria-readonly, the options keep the same focus ring as editable ones, and arrow keys move focus without changing the selection.
What you own
- Label: Set
label(or thelabelslot). Withhide-label, setradio-group-aria-labelto name the group. - Validation messages: Put group-level copy in
supporting-textand row-level copy in each option'ssupportingText, each with itsintent(see Validation). - 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-radio-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 with aria-required, aria-invalid and aria-readonly | A group label |
| 2.1.1 Keyboard | One Tab stop; arrow keys move and select, skipping disabled options | — |
| 2.4.7 Focus visible | A focus ring in every state, read-only and Windows contrast themes included | Don't override focus styles |
| 3.3.1 Error identification | In danger, the group message describes every radio | A sensible default, or an error when nothing is chosen |
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.