Toggle switch
On/off switch with a soft movement of the knob.
BackgroundGridAccent
Corners
SharpRound
Shadow
NoneStrong
Motion
NoneBounce
<style>
.ux-switch{display:inline-flex;align-items:center;gap:12px;cursor:pointer;font:500 15px system-ui;color:var(--fg,#14151a)}
.ux-switch input{position:absolute;opacity:0}
.ux-switch span{position:relative;width:44px;height:26px;border-radius:var(--rp,99px);background:var(--line,#cfd2da);transition:background var(--dur,.2s) var(--ease,ease)}
.ux-switch span::after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform var(--dur,.25s) var(--ease,cubic-bezier(.3,1.5,.5,1))}
.ux-switch input:checked+span{background:var(--accent,#cc4a26)}
.ux-switch input:checked+span::after{transform:translateX(18px)}
.ux-switch input:focus-visible+span{outline:2px solid var(--accent,#cc4a26);outline-offset:2px}
.ux-switch em{font-style:normal}
</style>
<label class="ux-switch">
<input type="checkbox" checked>
<span></span>
<em>Dark mode</em>
</label>When to use it
Reach for this when someone has to pick from a small, visible set of options rather than typing free text. It works best when every choice fits on screen at once.
Accessibility
It is fully keyboard operable: tab to it and use the keys you would expect (space, enter or the arrow keys) to change its value, with a visible focus ring so sighted keyboard users can always see where they are. It has no JavaScript dependency, so it keeps working if a script fails to load, and it is built on native form controls or semantics rather than divs pretending to be one. Colors are read from CSS custom properties, so they follow your light or dark theme and you can raise contrast globally without touching this component.