Radio
catnip-radio uses a visually hidden native <input type="radio"> for semantics and keyboard support, including the invalid and read-only states. You provide the option label.
Keyboard
| Key | Behaviour |
|---|---|
| Space | Select the radio when focused. |
Standalone radios don't move with the arrow keys and each is its own Tab stop, even when they share a name: every catnip-radio has its own shadow root, and native radio grouping only works inside one. Use Radio Group for a set of options; in development a console warning fires when standalone radios share a name.
A read-only radio remains in the keyboard focus model while pointer and keyboard selection changes are prevented.
Screen readers
- The native radio input drives the semantics.
intent="danger"setsaria-invalidfor validation states.readonly: HTML has no read-only radio, andaria-readonlybelongs on aradiogroup, not aradio. A standalone read-only radio adds a hidden “Read-only” (locale keyfieldLabel.readonly) to its description instead; it used to setaria-disabled, which was heard as “unavailable”. Insidecatnip-radio-group, the group'sreadonlyputsaria-readonlyon the radiogroup.
Visual
- A read-only radio shows the same focus ring as an editable one, and keeps its read-only fill and border.
What you own
- Label: Provide a visible label in the default slot, or set
radio-aria-labelwhen the slot is empty. - Grouping: Put related options in
catnip-radio-group, which gives one Tab stop, arrow keys, and a named group. Don't build a group from standalonecatnip-radioelements. - 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-radioelement'sidnames the inner control when the field has no label of its own, and clicking it focuses and selects the radio. 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 | Native radio; read-only adds a hidden “Read-only” instead of being heard as unavailable | Put related radios in catnip-radio-group |
| 2.1.1 Keyboard | Space selects | Use catnip-radio-group for arrow keys and one Tab stop |
| 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 | The whole row, circle and label, is the target | — |
This table says who handles what. It isn't a conformance claim: WCAG conformance is claimed for a page or a process.
Known issues
- Standalone radios don't form a group, even with a shared
name: each has its own shadow root. Use Radio Group.