FormsCheckbox and Radio Styles
Styled native checkboxes, radio buttons, option cards and chip toggles that keep their keyboard behaviour, group labels and a strong focus ring.
A group of settings-style switches built on real checkboxes with role switch, visible On and Off text and a disabled example.
Checked on 3 December 2026 in Chrome 143.0.7499.169: 12 automated checks. What the checks are
<section class="tsg" aria-labelledby="tsg-title">
<div class="tsg__card">
<fieldset class="tsg__group">
<legend class="tsg__legend" id="tsg-title">Example preferences</legend>
<p class="tsg__note">Example only. Nothing is saved.</p>
<div class="tsg__row">
<div class="tsg__copy">
<label class="tsg__label" for="tsg-summary">Weekly summary</label>
<span class="tsg__desc" id="tsg-summary-desc">A short digest sent once a week.</span>
</div>
<span class="tsg__state" aria-hidden="true"><span class="tsg__on">On</span><span class="tsg__off">Off</span></span>
<input class="tsg__input" type="checkbox" role="switch" id="tsg-summary" aria-describedby="tsg-summary-desc" checked>
</div>
<div class="tsg__row">
<div class="tsg__copy">
<label class="tsg__label" for="tsg-news">Product news</label>
<span class="tsg__desc" id="tsg-news-desc">Occasional notes about new features.</span>
</div>
<span class="tsg__state" aria-hidden="true"><span class="tsg__on">On</span><span class="tsg__off">Off</span></span>
<input class="tsg__input" type="checkbox" role="switch" id="tsg-news" aria-describedby="tsg-news-desc">
</div>
<div class="tsg__row">
<div class="tsg__copy">
<label class="tsg__label" for="tsg-motion">Reduce motion</label>
<span class="tsg__desc" id="tsg-motion-desc">Replace sliding and fading with quick changes.</span>
</div>
<span class="tsg__state" aria-hidden="true"><span class="tsg__on">On</span><span class="tsg__off">Off</span></span>
<input class="tsg__input" type="checkbox" role="switch" id="tsg-motion" aria-describedby="tsg-motion-desc" checked>
</div>
<div class="tsg__row tsg__row--disabled">
<div class="tsg__copy">
<label class="tsg__label" for="tsg-beta">Early features</label>
<span class="tsg__desc" id="tsg-beta-desc">Not available in this example.</span>
</div>
<span class="tsg__state" aria-hidden="true"><span class="tsg__on">On</span><span class="tsg__off">Off</span></span>
<input class="tsg__input" type="checkbox" role="switch" id="tsg-beta" aria-describedby="tsg-beta-desc" disabled>
</div>
</fieldset>
</div>
</section>.tsg {
--tsg-surface: #ffffff;
--tsg-fg: #1b2032;
--tsg-muted: #4a5266;
--tsg-line: #d3d8e6;
--tsg-off: #69708a;
--tsg-on: #4338ca;
--tsg-knob: #ffffff;
--tsg-state-on: #3730a3;
--tsg-row-hover: #f5f6fd;
--tsg-ring: #4338ca;
box-sizing: border-box;
width: min(100%, 30rem);
color: var(--tsg-fg);
}
.tsg *, .tsg *::before, .tsg *::after { box-sizing: border-box; }
.tsg__card { padding: 1.25rem 1.25rem 0.35rem; background: var(--tsg-surface); border: 1px solid var(--tsg-line); border-radius: 16px; box-shadow: 0 10px 30px -18px rgba(27, 32, 50, 0.4); }
.tsg__group { min-width: 0; margin: 0; padding: 0; border: 0; }
.tsg__legend { float: left; width: 100%; padding: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.tsg__note { clear: both; margin: 0.3rem 0 0.5rem; color: var(--tsg-muted); font-size: 0.875rem; line-height: 1.5; }
.tsg__row {
display: grid;
grid-template-columns: 1fr auto auto;
align-items: center;
gap: 0.9rem;
padding: 0.8rem 0.5rem;
margin: 0 -0.5rem;
border-top: 1px solid var(--tsg-line);
}
.tsg__row:first-of-type { border-top: 0; }
.tsg__row:hover:not(.tsg__row--disabled) { background: var(--tsg-row-hover); }
.tsg__copy { display: grid; gap: 0.15rem; min-width: 0; }
.tsg__label { font-weight: 600; cursor: pointer; }
.tsg__desc { color: var(--tsg-muted); font-size: 0.875rem; line-height: 1.4; }
.tsg__state { min-width: 2.2rem; text-align: right; font-size: 0.875rem; font-weight: 700; }
.tsg__on { display: none; color: var(--tsg-state-on); }
.tsg__off { color: var(--tsg-muted); }
.tsg__row:has(.tsg__input:checked) .tsg__on { display: inline; }
.tsg__row:has(.tsg__input:checked) .tsg__off { display: none; }
.tsg__input {
appearance: none;
appearance: none;
position: relative;
flex: none;
width: 52px;
height: 30px;
margin: 0;
background: var(--tsg-off);
border: 2px solid transparent;
border-radius: 999px;
cursor: pointer;
transition: background-color 0.2s ease;
}
.tsg__input::before {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 20px;
height: 20px;
background: var(--tsg-knob);
border-radius: 50%;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
transition: transform 0.2s ease;
}
.tsg__input:checked { background: var(--tsg-on); }
.tsg__input:checked::before { transform: translateX(22px); }
.tsg__input:focus-visible { outline: 3px solid var(--tsg-ring); outline-offset: 3px; }
.tsg__input:disabled { cursor: not-allowed; opacity: 0.55; }
.tsg__row--disabled .tsg__label { cursor: not-allowed; color: var(--tsg-muted); }
@media (max-width: 24em) {
.tsg__card { padding: 1rem 1rem 0.3rem; }
.tsg__row { grid-template-columns: 1fr auto; }
.tsg__state { display: none; }
}
@media (forced-colors: active) {
.tsg__input { border-color: ButtonText; }
.tsg__input:checked { background: Highlight; }
}
@media (prefers-color-scheme: dark) {
.tsg {
--tsg-surface: #1a1e2e;
--tsg-fg: #edf0fa;
--tsg-muted: #b9bfd3;
--tsg-line: #3a4157;
--tsg-off: #7a829f;
--tsg-on: #aeb1ff;
--tsg-knob: #12141f;
--tsg-state-on: #c3c5ff;
--tsg-row-hover: #20253a;
--tsg-ring: #c9cbff;
}
.tsg__card { box-shadow: none; }
.tsg__input::before { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
.tsg__input, .tsg__input::before { transition: none; }
}Written by the author of the snippet. Each note has a test step or a markup check that reads the page.
FormsStyled native checkboxes, radio buttons, option cards and chip toggles that keep their keyboard behaviour, group labels and a strong focus ring.
FormsA contact form with per-field rules, messages tied to each field and an error summary that links to the first problem, using XON.
FormsText, email, number, search and multi-line fields with a label, a hint and an error line tied to the field, switched on by the browser's own checks.