{
  "id": "theme-toggle",
  "name": "Day / Night Toggle",
  "category": "forms",
  "tags": [
    "dark mode",
    "theme",
    "toggle",
    "switch",
    "sun",
    "moon",
    "checkbox"
  ],
  "description": "A dark-mode switch where the sun slides across and turns into a crescent moon.",
  "url": "https://copy-css.com/snippets/theme-toggle",
  "markdown": "https://copy-css.com/snippets/theme-toggle.md",
  "html": "<label class=\"theme-toggle\">\n  <input type=\"checkbox\" aria-label=\"Dark mode\">\n  <span></span>\n</label>",
  "css": ".theme-toggle {\n  position: relative;\n  display: inline-block;\n  width: 64px;\n  height: 34px;\n}\n\n.theme-toggle input {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  margin: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n\n.theme-toggle span {\n  position: absolute;\n  inset: 0;\n  border-radius: 999px;\n  background: #38bdf8;\n  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);\n  transition: background 0.4s ease;\n}\n\n/* The sun */\n.theme-toggle span::before {\n  content: \"\";\n  position: absolute;\n  top: 4px;\n  left: 4px;\n  width: 26px;\n  height: 26px;\n  border-radius: 50%;\n  background: #fde047;\n  box-shadow:\n    inset 0 0 0 0 #f8fafc,\n    0 0 10px 2px rgba(253, 224, 71, 0.6);\n  transition: transform 0.4s cubic-bezier(0.4, 1.4, 0.6, 1), background 0.4s ease, box-shadow 0.4s ease;\n}\n\n.theme-toggle input:checked + span {\n  background: #1e1b4b;\n}\n\n/* ...becomes the moon */\n.theme-toggle input:checked + span::before {\n  background: rgba(253, 224, 71, 0);\n  box-shadow:\n    inset -9px -3px 0 0 #f8fafc,\n    0 0 10px 2px rgba(248, 250, 252, 0);\n  transform: translateX(30px);\n}\n\n.theme-toggle input:focus-visible + span {\n  outline: 2px solid #6366f1;\n  outline-offset: 3px;\n}",
  "features": [
    "transitions",
    "transforms",
    "box shadows",
    "the :checked state (no JavaScript)",
    "keyboard focus styles"
  ],
  "customProperties": []
}
