Susegad UI Accessibility GitHub

How this site looks

The view settings need JavaScript. Every page reads well without them.

Mood

The same pages, in three moods.

Theme

Components

Radio group

A real fieldset of native radios: arrow keys, one choice per name, required and submitting all stay the browser's, with or without JavaScript.

quiet warm playful

Open the live demo npx @susegad/cli add radio

Stands on: Core, Core: components, Engine, Tokens

The prompt

the prompt

One choice from a few, the way a paper form circles an answer.

A real <fieldset> of native radios. The browser keeps doing what it always has: the arrow keys move and choose, one name allows one choice, required stops the form, the chosen value is sent. The register only changes how the circles are drawn.

<link rel="stylesheet" href="susegad/components/radio/radio.css">
<script type="module" src="susegad/components/radio/radio.js"></script>

<sg-radio-group orientation="row">
  <fieldset>
    <legend>Guests</legend>
    <label><input type="radio" name="guests" value="2" checked> 2</label>
    <label><input type="radio" name="guests" value="4"> 4</label>
  </fieldset>
</sg-radio-group>
AttributeValuesWhat it does
orientationcolumn (default), rowLays the choices out down or across.
seedany wordThe hand-drawn rings. Defaults to the legend.

The prompt

Make a radio group web component that wraps a real <fieldset> with a <legend> and native radios in labels, so it works with JavaScript off and keeps the browser's arrow keys, grouping, required and submission. Style each radio with appearance: none as a hairline circle with a CSS dot that scales in when chosen, aligned to the first line of its label with the lh unit. Give it three registers. Quiet: exactly that. Warm: over each radio, in the same grid cell and aria-hidden, draw a pencil circle whose ends cross, and for the chosen one an ink dot and an inked ring drawn round it the way a pen circles an answer on a paper form: a leaning oval a quarter bigger than a plain ring, well past the radio's edge, whose radius wavers with seeded noise, started at a seeded angle and carried past its start, spreading outward as it goes so the overlap shows at 1x. When the choice moves, draw the new ring in. Playful: a bold inked circle for each, and for the chosen one a kolam flower in place of the circle: four round petal loops drawn round the pulli, filling the circle with a notch between each pair, the pulli left as a hole of paper, blooming with a small turn. Show disabled radios dashed in every register. In forced-colours mode bring back the native radios; under reduced motion, no movement.

Words to code

When you sayTechniqueWhat happens
a real <fieldset> with a <legend>native firstThe group is announced by its legend ("group, Guests"). The browser's arrow keys, Tab stop on the chosen radio, skipping disabled ones and required all work with no script.
the way a pen circles an answernoisehandRing(seed, opts) walks 1 + overlap turns of a circle, adding seeded Perlin noise to the radius and starting at a seeded angle. spread ramps the radius outward over the last third of a turn, so the overrun runs outside the start instead of on top of it.
a leaning oval a quarter biggergeometryThe chosen ring is r: 10.4 (the old ring was 8.6), squash: 0.8 and tilt: -14, carried 0.3 turns past its start with a spread of 1.5. It spills past the 20-unit box; the SVG has overflow: visible. The browser check measures it at 1.23 times the radio's width.
draw the new ring ina real changeThe group counts real change events; the ring's stroke-dashoffset animates only when a new radio has just been chosen, never on first paint.
a kolam flower in place of the circlemotifFour cubic petals from the centre out to 8.4 units and back, round at the tip, filled in ink at 88%; the notches between them give the flower its outline at 20 px. The pulli is a 1.7-unit circle in the surface colour, and the plain ring is hidden while the flower shows.
dashed in every registerstateinput:disabled ~ .sg-radio-art dashes the pencil and the ink circle; the native disabled state keeps it out of the arrow keys.
bring back the native radiosforced coloursappearance: auto and the drawing hidden under forced-colors: active.

Accessibility

  • Keyboard: Tab lands on the chosen radio (or the first, if none); the arrow keys move and choose and skip disabled radios; Tab leaves the group. All native.
  • A screen reader hears the legend, then each radio's label and state.
  • Circles, rings and dots are 3:1 or more on every surface in every palette and theme (tested).
  • The drawing is aria-hidden and never takes a click. Forced colours: the system radios. Reduced motion: no movement.

Credit

The kolam dot is a pulli with petal loops, from the dot-grid kolam drawn at thresholds across South India. Tier: shared practice with local forms, used here as a small ornament.

<sg-radio-group> wraps a <fieldset> of native radios. The fieldset, the legend and the radios do all the work, with or without JavaScript.

Use

<link rel="stylesheet" href="susegad/components/radio/radio.css">
<script type="module" src="susegad/components/radio/radio.js"></script>

<sg-radio-group>
  <fieldset>
    <legend>Arriving by</legend>
    <label><input type="radio" name="arrive" value="car" required> Car</label>
    <label><input type="radio" name="arrive" value="train" required> Train to Thivim</label>
    <label><input type="radio" name="arrive" value="boat" disabled> Boat (closed in the monsoon)</label>
  </fieldset>
</sg-radio-group>

Always give the group a <legend>: it is the question the radios answer, and what a screen reader says first.

Attributes and properties

ValuesDefault
orientationcolumn, rowcolumn
seedany stringthe legend
registerquiet, warm, playfulinherited
value (property)the chosen radio's value, or ''; setting it chooses and fires change
radios (property)the native radios, in order

A server can swap the options (htmx); the drawings follow.

Registers

LookMotion
quiet (and no JS)hairline circles, a crisp dotthe dot scales in under 200ms
warmpencil circles whose ends cross; the choice gets an ink dot and is circled in ink, a leaning oval a quarter bigger that runs past its start, as a pen circles an answerthe ring is drawn in when the choice moves
playfulbold inked circles; the choice becomes a four-petalled kolam flower in place of its circlethe kolam blooms with a small turn

Reduced motion: no movement. Forced colours: the system radios.

Accessibility

How this component meets WCAG 2.2 level A and AA, criterion by criterion, how each was checked, and what your page still owns.

  • Meets 15
  • Meets with author's part 4
  • Not applicable 1
CriterionStatusHow it was checked
1.1.1 Non-text contentMeetsThe drawn circles, rings and dots are aria-hidden and carry no meaning; the label text is the name: packages/components/radio/radio.check.mjs, "the drawings are hidden from assistive tech" in warm and playful.
1.3.1 Info and relationshipsMeetsA native <fieldset> with a <legend> and native radios in their <label>s. radio.check.mjs: "the group is announced by its legend, with its radios" (group "Guests", radio "6, the whole house" [checked]) in each register, and with JavaScript off "the form submits one value per group".
1.3.5 Identify input purposeNot applicableA choice among options holds no personal data of a kind the criterion's list names.
1.4.1 Use of colorMeetsThe chosen answer is a filled dot, a ring a quarter bigger or the kolam flower, never a colour change alone (packages/components/radio/radio.check.mjs: "exactly one mark per group, on the chosen radio"; warm "the chosen answer is circled in ink a quarter bigger"; playful "the chosen radio becomes the kolam flower in place of the circle").
1.4.3 Contrast (minimum)MeetsLabels are --sg-text on the page surface: packages/tokens/tokens.test.js ("AA: every text role on every surface is 4.5:1 or more") for every palette and theme. Axe: tools/axe.mjs --url /packages/components/radio/demo.html, 0 violations across 6 runs (3 registers, light and dark), desktop, 2026-10-07.
1.4.4 Resize textMeetsManual test, 2026-10-07: demo with the root font size at 200 percent, three registers, no sideways scroll and nothing clipped (throwaway Playwright script). radio.check.mjs also keeps the circle level with Marathi, Kannada and Konkani labels.
1.4.10 ReflowMeetsManual test, 2026-10-07: demo at 320 CSS px, three registers, no sideways scroll (document width 320). A long label wraps beside its circle.
1.4.11 Non-text contrastMeetspackages/components/radio/radio.test.js: "1.4.11: <palette> <theme>: circles, rings and dots are 3:1 or more", for every palette in light and dark. The focus ring is tested 3:1 or more on every surface in packages/tokens/tokens.test.js.
1.4.12 Text spacingMeetsManual test, 2026-10-07: the WCAG text-spacing values (line height 1.5, letter 0.12em, word 0.16em, paragraph 2em) injected on the demo, three registers, no clipped or overlapping text (throwaway Playwright script). No check in the repository asserts it yet.
2.1.1 KeyboardMeetsradio.check.mjs: Tab lands on the chosen radio (or the first when none is chosen); the arrow keys move and choose, wrap from the first to the last, and skip a disabled radio, in each register.
2.1.2 No keyboard trapMeetspackages/components/radio/radio.js listens to change only: it binds no keydown and sets no tabindex, and the native radios give Tab and the arrows as for any group.
2.4.3 Focus orderMeetsradio.check.mjs: with nothing chosen Tab lands on the first radio; with one chosen it lands there; the group is one stop, as the platform does it.
2.4.7 Focus visibleMeetstools/touch.check.mjs Tabs onto the group in each register and requires a focus style; radio.check.mjs moves focus with the arrows and packages/tokens/tokens.test.js asserts the ring colour 3:1.
2.4.11 Focus not obscured (minimum)Meets with author's partManual test, 2026-10-07: packages/components/radio/radio.css uses no position: fixed or sticky, and a document scan of the demo found none. A sticky header or banner the page adds can cover a radio that is scrolled to.
2.5.3 Label in nameMeetsThe accessible name is the visible label text: radio.check.mjs reads radio "6, the whole house".
2.5.8 Target size (minimum)Meets with author's partManual test, 2026-10-07, 390 px touch: the circle alone is 18.5 by 18.5 px, but the click target is the whole <label>, 25.7 px tall in all three registers and 35.9 px or more wide for the shortest label ("2"). Meets only while each radio stays inside its <label>. No check in the repository asserts target size for the radio yet.
3.2.2 On inputMeetsradio.js listens to change only and draws the mark; it submits nothing and moves no focus (radio.check.mjs: arrows choose, the form is sent only by its own button).
3.3.1 Error identificationMeets with author's partA required group with nothing chosen is stopped by the browser (radio.check.mjs, "no JS: a required group with nothing chosen stops the form"), which then says why in its own words. A page that wants its own words puts an sg-field-note or message by the group.
3.3.2 Labels or instructionsMeets with author's partThe <legend> is the question and each <label> an answer, both native (packages/components/radio/radio.check.mjs, "the group is announced by its legend, with its radios"). Their text is the author's.
4.1.2 Name, role, valueMeetsNative radios in a named group; the checked state is the native one (radio.check.mjs, radio ... [checked], "value writes and reads"). Axe with JavaScript off: tools/axe.mjs --no-js --url /packages/components/radio/demo.html, 0 violations across 6 runs, 2026-10-07.

The page author owns:

  • The legend (the question) and each label, in the language of the page, and lang on a label in another language (3.1.2).
  • Keeping each radio inside its <label>, so the whole row is the target (2.5.8).
  • The words of an error, if the browser's own are not enough (3.3.1).
  • Sticky headers and banners that could cover a radio when it takes focus (2.4.11).
  • The colours the page sets behind the group, if it overrides the tokens.

How it behaves

  • Keyboard: native. Tab to the chosen radio, arrows to move and choose, disabled radios skipped.
  • Required: put required on the radios; the browser stops the form and says why.
  • Contrast: circles, rings and dots are 3:1 or more on every surface (WCAG 1.4.11), tested for every palette and theme.

All 57 tables, and how the library tests

Budget

Behaviour 5.8 KB of 12 KB (radio.js + radio.core.js); skins 0.3, 2.5 and 1.4 KB.