{
  "id": "toggle-switch",
  "name": "Toggle Switch",
  "category": "forms",
  "tags": [
    "switch",
    "toggle",
    "checkbox",
    "mobile"
  ],
  "description": "An accessible mobile-style toggle switch built on a real checkbox.",
  "url": "https://copy-css.com/snippets/toggle-switch",
  "markdown": "https://copy-css.com/snippets/toggle-switch.md",
  "html": "<label class=\"switch\">\n  <input type=\"checkbox\" checked aria-label=\"Notifications\">\n  <span class=\"slider\"></span>\n</label>",
  "css": ".switch {\n  position: relative;\n  display: inline-block;\n  width: 52px;\n  height: 30px;\n}\n\n.switch input {\n  width: 0;\n  height: 0;\n  opacity: 0;\n}\n\n.switch .slider {\n  position: absolute;\n  inset: 0;\n  border-radius: 999px;\n  background: #d1d5db;\n  cursor: pointer;\n  transition: background 0.25s ease;\n}\n\n.switch .slider::before {\n  content: \"\";\n  position: absolute;\n  top: 3px;\n  left: 3px;\n  width: 24px;\n  height: 24px;\n  border-radius: 50%;\n  background: #fff;\n  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);\n  transition: transform 0.25s ease;\n}\n\n.switch input:checked + .slider {\n  background: #22c55e;\n}\n\n.switch input:checked + .slider::before {\n  transform: translateX(22px);\n}\n\n.switch input:focus-visible + .slider {\n  outline: 2px solid #22c55e;\n  outline-offset: 2px;\n}",
  "features": [
    "transitions",
    "transforms",
    "box shadows",
    "the :checked state (no JavaScript)",
    "keyboard focus styles"
  ],
  "customProperties": []
}
