Founding sponsorYour name here
Switch
Immediate
Checkbox
Independent
Radio
One of many

Switch vs. Checkbox vs. Radio

/ <input type="checkbox" role="switch"> · <input type="checkbox"> /

also called toggle switch, check box, radio button, option button

A switch controls a binary setting and communicates that the change takes effect immediately, like turning notifications on. A checkbox represents an independent form value and may wait for Save or Submit; several checkboxes can be selected. Radio buttons form a named group in which choosing one option clears the others.

If you called it…

the on off sliding controlthe square box with a checkmarkthe circles where only one can be pickeda setting that changes immediatelychoose several versus choose exactly one

…you meant a switch vs. checkbox vs. radio.

Anatomy — every part, named

  1. 1
    Switch thumbrole="switch"

    “The little circle that slides left and right” is the switch thumb.

  2. 2
    Switch trackrole="switch"

    “The rounded pill behind the moving circle” is the switch track.

  3. 3
    Checkbox checkmark<input type="checkbox">

    “The tick that appears inside the square box” is the checkbox checkmark.

  4. 4
    Radio selection dot<input type="radio">

    “The filled dot inside the chosen circle” is the radio selection dot.

Prompt — paste into your agent

Use an <input type="checkbox" role="switch"> for the binary on/off setting, a native <input type="checkbox"> for each independent checked choice, and same-name <input type="radio"> controls when exactly one option is allowed. Give every control a visible clickable label and expose its checked state through the native control.

Debug prompt — when it misbehaves

Paste this, then describe what you’re seeing — it hands your agent the classic failure modes to rule out first.

Debug my switch/checkbox/radio. Rule out: the control flipping visually while state stays stale — controlled input without onChange; label clicks not toggling because for/id association is missing; radios not behaving as a group because their name attributes differ; the indeterminate checkbox state gone — it is settable only from JS, not markup. The symptom:

In code

The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).

HTML<input type="checkbox" role="switch">
HTML<input type="checkbox">
HTML<input type="radio">
shadcn/uiSwitch
shadcn/uiCheckbox

See also

Search

Describe the UI element you're thinking of