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
htmlFor and id. This is our own choice, not something the judges decided.Don't: The words are a span
Notification settings
Departure email: off
Changes made: 0 · Presses on the words: 0
Don't: A Label with no htmlFor
Notification settings
Departure email: off
Changes made: 0 · Presses on the words: 0
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
Switchwithid="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 sameonCheckedChange. - In a
justify-betweenrow, where the text sits at the far side from the switch, tie the two withhtmlForandid, 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 eachidfrom the setting's key or fromuseId(). - 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 nohtmlForat the other end of the row. - Give every mapped
Switchthe sameid, so each label flips the first one. - Fake it with an
onClickon the rowdivthat 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
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 2.5.8 Target Size (Minimum) |
| Material Design | Judge | No position | |
| Apple Human Interface Guidelines | Judge | No position | |
| Carbon Design System | Judge | Supports | Toggle: usage |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert 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
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.