Formtoggleswitchiosform
iOS-Style Toggle Switch
A pure CSS toggle switch styled like iOS. No JavaScript needed — uses the native checkbox input with custom appearance. Fully accessible with keyboard and screen readers.
.toggle {
appearance: none;
width: 48px;
height: 28px;
background: #333;
border-radius: 14px;
position: relative;
cursor: pointer;
transition: background 0.2s;
}
.toggle::before {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 24px;
height: 24px;
background: white;
border-radius: 50%;
transition: transform 0.2s;
}
.toggle:checked {
background: #8b5cf6;
}
.toggle:checked::before {
transform: translateX(20px);
}