{
  "id": "material-toggle-switch",
  "name": "Material Toggle Switch",
  "category": "forms",
  "tags": [
    "material design",
    "android",
    "toggle",
    "switch",
    "single element",
    "appearance"
  ],
  "description": "An Android-style switch made from a single input, with a slim track, an oversized thumb and a focus halo.",
  "url": "https://copy-css.com/snippets/material-toggle-switch",
  "markdown": "https://copy-css.com/snippets/material-toggle-switch.md",
  "html": "<label class=\"tgl-md\">\n  <input type=\"checkbox\" role=\"switch\" checked>\n  Dark theme\n</label>",
  "css": ".tgl-md {\n  display: inline-flex;\n  align-items: center;\n  gap: 14px;\n  color: #3b0764;\n  font: 500 15px system-ui, sans-serif;\n  cursor: pointer;\n}\n\n.tgl-md input {\n  position: relative;\n  width: 36px;\n  height: 14px;\n  margin: 0 4px;\n  border-radius: 999px;\n  background: #d4d4d8;\n  -webkit-appearance: none;\n  appearance: none;\n  cursor: pointer;\n  transition: background 0.2s ease;\n}\n\n.tgl-md input::before {\n  content: \"\";\n  position: absolute;\n  top: 50%;\n  left: -4px;\n  width: 22px;\n  height: 22px;\n  border-radius: 50%;\n  background: #fafafa;\n  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);\n  transform: translateY(-50%);\n  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;\n}\n\n.tgl-md input:checked {\n  background: #d8b4fe;\n}\n\n.tgl-md input:checked::before {\n  background: #7e22ce;\n  transform: translate(22px, -50%);\n}\n\n.tgl-md input:focus-visible {\n  outline: none;\n}\n\n.tgl-md input:focus-visible::before {\n  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 10px rgba(126, 34, 206, 0.18);\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tgl-md input,\n  .tgl-md input::before {\n    transition: none;\n  }\n}",
  "features": [
    "transitions",
    "transforms",
    "box shadows",
    "Flexbox",
    "the :checked state (no JavaScript)",
    "keyboard focus styles",
    "reduced-motion support"
  ],
  "customProperties": []
}
