The switch is a plain <input type="checkbox"> with appearance: none to remove the default box, and the knob is its ::before pseudo-element. Because it's still a real checkbox, everything you'd expect comes free: clicking anywhere on the label toggles it, Space toggles it from the keyboard, and it submits with forms.
role="switch" tells screen readers to announce it as a switch ("on"/"off") rather than a checkbox ("checked"), which matches what people see. The knob's slight overshoot comes from a springy cubic-bezier easing.
With reduced motion on, the knob still slides, just faster.