Skip to content

FRM-016b Let a click on a switch's text turn it on or off, as a click on the switch does

Level
Guideline, our choice
Verdict
Insufficient evidence (1 of 3 judges spoke)
Area
Forms
Status
proposed, version 1.0.0

Rule

When a switch shows its own text beside it, a click, tap or pen press on that text turns the switch on or off exactly as a press on the switch does.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: The words turn the switch on

Notification settings

Departure email: off

Changes made: 0

Click the words Email me before departure, then the switch, or Tab to the switch and press Space. Each one flips the setting and adds one to the count, although the words sit at the far side of the row. The label is tied to the switch with htmlFor and id. This is our own choice, not something the judges decided.

Don't: The words are a span

Notification settings

Email me before departure

Departure email: off

Changes made: 0 · Presses on the words: 0

Click the words Email me before departure. Nothing changes: the presses on the words rise, the changes stay at zero, and a line says why. The switch still has a name in code. Only a press on the switch flips it.

Don't: A Label with no htmlFor

Notification settings

Departure email: off

Changes made: 0 · Presses on the words: 0

Click the words Email me before departure. It is a real Label, but it names no control, so a press on it does nothing and the changes stay at zero. Only the switch flips.

Why

A switch and its text read as one setting, and people aim at the words as often as at the small track. Text that does nothing turns a near miss into a lost press. WCAG does not require this; a responding label serves the same need as WCAG 2.2, 2.5.8 Target Size (Minimum), and text that does not respond does not by itself fail it. Checkboxes and radio buttons are FRM-016a, a rule.

Our reasons

Fewer than two judges have spoken about the text of a switch, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. We make it for two reasons.

  • One setting, one target. The words and the track say the same thing, so a press on either should do the same.
  • One way of building. The switch then works like the checkbox and radio button in FRM-016a, with the same label tied to the same kind of control.

Do

  • In a ferry app's settings, the row Email me before departure holds a shadcn Switch with id="departure-email" and a <Label htmlFor="departure-email">. A tap on the words turns the switch on and does everything a tap on the track does, firing the same onCheckedChange.
  • In a justify-between row, where the text sits at the far side from the switch, tie the two with htmlFor and id, or wrap the row in one <label>.
  • A whole row may act as the label, as long as it holds no other control, such as a Learn more link or a help button.
  • In a list of settings built with .map(), build each id from the setting's key or from useId().
  • A switch that applies its setting at once does exactly the same when its text is pressed, no more. FRM-012a still applies.

Don't

  • Put Email me before departure in a <span> beside the switch, so the words do nothing.
  • Use a <Label> with no htmlFor at the other end of the row.
  • Give every mapped Switch the same id, so each label flips the first one.
  • Fake it with an onClick on the row div that flips the state. A tap on the switch itself then flips it twice, and nothing is tied for assistive technology.

Exceptions

  • No text of its own. A switch with no visible text beside it is outside this guideline. Whether it needs text is FRM-001, and its name in code is FRM-010.
  • Target size. This guideline does not make a small switch pass ACT-006.
  • A product that chooses otherwise. This is a guideline. A product whose switch text does not respond still names the switch as FRM-010 asks.

Verdict

Insufficient evidence (1 of 3 judges spoke). Only the judges decide; the expert witnesses are shown but do not vote. The judges do not settle this one, so it is a guideline: our own choice, with our reasons above. How verdicts work

Stances on FRM-016b
SourceRoleStancePage
WCAG 2.2LawSupports2.5.8 Target Size (Minimum)
Material DesignJudge No position
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge SupportsToggle: usage
GOV.UK Design SystemExpert witness No position
Nielsen Norman GroupExpert witness No position

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Forms: 15 rules and 12 guidelines · All rules