{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggle-theme-switch",
  "type": "registry:component",
  "title": "Theme Switch",
  "description": "A sun and moon switch. The thumb morphs between a rayed sun and a crescent while clouds drift out and stars twinkle in.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "toggle",
    "switch",
    "theme",
    "dark mode",
    "sun",
    "moon"
  ],
  "docs": "https://hyperblur.dev/effects/toggle-theme-switch",
  "files": [
    {
      "path": "registry/hyperblur/toggle-theme-switch.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/toggle-theme-switch.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ToggleThemeSwitchProps\n  extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, \"onChange\" | \"children\" | \"defaultChecked\"> {\n  checked?: boolean;\n  defaultChecked?: boolean;\n  onCheckedChange?: (checked: boolean) => void;\n  size?: number;\n  label?: string;\n  accent?: string;\n  disabled?: boolean;\n  name?: string;\n}\n\nconst css = `\n.hb-qn1 {\n  position: relative;\n  display: inline-block;\n  box-sizing: border-box;\n  flex: none;\n  width: calc(var(--hb-qn1-h) * 2);\n  height: var(--hb-qn1-h);\n  margin: 0;\n  border-radius: 999px;\n  font: inherit;\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-qn1 *, .hb-qn1 *::before, .hb-qn1 *::after { box-sizing: border-box; }\n.hb-qn1[data-disabled=\"true\"] { opacity: 0.5; cursor: not-allowed; }\n.hb-qn1-in {\n  position: absolute;\n  inset: 0;\n  z-index: 3;\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  opacity: 0;\n  cursor: inherit;\n}\n.hb-qn1-track {\n  position: absolute;\n  inset: 0;\n  overflow: hidden;\n  border-radius: inherit;\n  background: linear-gradient(180deg, #7db8ff 0%, #cfe6ff 100%);\n  box-shadow: inset 0 1px 4px rgba(10, 30, 70, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);\n}\n.hb-qn1-in:focus-visible ~ .hb-qn1-track { outline: 2px solid var(--hb-qn1-a); outline-offset: 3px; }\n.hb-qn1-night {\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(180deg, #080c1f 0%, #1c2552 100%);\n  opacity: 0;\n  transition: opacity 0.55s ease;\n}\n.hb-qn1-stars {\n  position: absolute;\n  inset: 0;\n  width: 100%;\n  height: 100%;\n  opacity: 0;\n  transform: translateY(-35%);\n  transition: opacity 0.4s ease, transform 0.55s cubic-bezier(0.3, 1.2, 0.4, 1);\n}\n.hb-qn1-star { fill: #fff; animation: hb-qn1-tw 2.4s ease-in-out infinite; }\n.hb-qn1-star:nth-child(2n) { animation-delay: -0.8s; }\n.hb-qn1-star:nth-child(3n) { animation-delay: -1.6s; }\n.hb-qn1-clouds {\n  position: absolute;\n  right: 0;\n  bottom: 0;\n  width: 58%;\n  height: 74%;\n  fill: #fff;\n  opacity: 0.95;\n  transition: opacity 0.4s ease, transform 0.55s cubic-bezier(0.3, 1.2, 0.4, 1);\n}\n.hb-qn1-clouds-b { opacity: 0.6; }\n.hb-qn1-in:checked ~ .hb-qn1-track .hb-qn1-night { opacity: 1; }\n.hb-qn1-in:checked ~ .hb-qn1-track .hb-qn1-stars { opacity: 1; transform: translateY(0); }\n.hb-qn1-in:checked ~ .hb-qn1-track .hb-qn1-clouds { opacity: 0; transform: translateX(40%); }\n.hb-qn1-thumb {\n  position: absolute;\n  z-index: 1;\n  top: calc(var(--hb-qn1-h) * 0.125);\n  left: calc(var(--hb-qn1-h) * 0.125);\n  width: calc(var(--hb-qn1-h) * 0.75);\n  height: calc(var(--hb-qn1-h) * 0.75);\n  pointer-events: none;\n  filter: drop-shadow(0 0 5px rgba(255, 190, 50, 0.65));\n  transform: translateX(0);\n  transition: transform 0.55s cubic-bezier(0.6, -0.2, 0.3, 1.25), filter 0.55s ease;\n}\n.hb-qn1-in:checked ~ .hb-qn1-thumb {\n  transform: translateX(var(--hb-qn1-h));\n  filter: drop-shadow(0 0 5px rgba(190, 210, 255, 0.5));\n}\n.hb-qn1:active .hb-qn1-thumb { scale: 1.08; }\n.hb-qn1-svg { display: block; width: 100%; height: 100%; overflow: visible; }\n.hb-qn1-core {\n  fill: #ffc43d;\n  transform-box: fill-box;\n  transform-origin: center;\n  transition: fill 0.55s ease, transform 0.55s cubic-bezier(0.3, 1.3, 0.5, 1);\n}\n.hb-qn1-in:checked ~ .hb-qn1-thumb .hb-qn1-core { fill: #e9eefb; transform: scale(1.18); }\n.hb-qn1-rays {\n  stroke: #ffc43d;\n  stroke-width: 1.8;\n  stroke-linecap: round;\n  transform-box: view-box;\n  transform-origin: 12px 12px;\n  transition: transform 0.55s cubic-bezier(0.3, 1.2, 0.5, 1), opacity 0.35s ease;\n}\n.hb-qn1-in:checked ~ .hb-qn1-thumb .hb-qn1-rays { transform: rotate(80deg) scale(0.3); opacity: 0; }\n.hb-qn1-cut {\n  transform: translate(15px, -7px);\n  transition: transform 0.55s cubic-bezier(0.3, 1.2, 0.5, 1);\n}\n.hb-qn1-in:checked ~ .hb-qn1-thumb .hb-qn1-cut { transform: translate(0, 0); }\n.hb-qn1-crater { fill: #8b97c4; opacity: 0; transition: opacity 0.4s ease 0.2s; }\n.hb-qn1-in:checked ~ .hb-qn1-thumb .hb-qn1-crater { opacity: 0.35; }\n@keyframes hb-qn1-tw {\n  0%, 100% { opacity: 1; }\n  50% { opacity: 0.35; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qn1-night, .hb-qn1-stars, .hb-qn1-clouds, .hb-qn1-thumb, .hb-qn1-core, .hb-qn1-rays, .hb-qn1-cut, .hb-qn1-crater { transition: none; }\n  .hb-qn1-star { animation: none; }\n  .hb-qn1:active .hb-qn1-thumb { scale: 1; }\n}\n`;\n\nconst stars: [number, number, number][] = [\n  [10, 9, 1.1],\n  [19, 21, 0.8],\n  [25, 8, 0.9],\n  [31, 23, 1],\n  [14, 15.5, 0.6],\n  [36, 12, 0.7],\n];\n\nexport function ToggleThemeSwitch({\n  checked,\n  defaultChecked = false,\n  onCheckedChange,\n  size = 32,\n  label = \"Dark mode\",\n  accent = \"#7fb3ff\",\n  disabled = false,\n  name,\n  className = \"\",\n  style,\n  ...rest\n}: ToggleThemeSwitchProps) {\n  const maskId = `hb-qn1-${React.useId().replace(/:/g, \"\")}`;\n  const controlled = checked !== undefined;\n  const vars = {\n    \"--hb-qn1-h\": `${size}px`,\n    \"--hb-qn1-a\": accent,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-toggle-theme-switch\" precedence=\"default\">{css}</style>\n      <label className={`hb-qn1 ${className}`} style={vars} data-disabled={disabled} {...rest}>\n        <input\n          type=\"checkbox\"\n          role=\"switch\"\n          className=\"hb-qn1-in\"\n          aria-label={label}\n          name={name}\n          disabled={disabled}\n          {...(controlled ? { checked } : { defaultChecked })}\n          onChange={(e) => onCheckedChange?.(e.target.checked)}\n        />\n        <span className=\"hb-qn1-track\" aria-hidden=\"true\">\n          <span className=\"hb-qn1-night\" />\n          <svg className=\"hb-qn1-stars\" viewBox=\"0 0 64 32\" focusable=\"false\">\n            {stars.map(([x, y, r]) => (\n              <circle key={`${x}-${y}`} className=\"hb-qn1-star\" cx={x} cy={y} r={r} />\n            ))}\n          </svg>\n          <svg className=\"hb-qn1-clouds\" viewBox=\"0 0 40 24\" focusable=\"false\">\n            <g className=\"hb-qn1-clouds-b\">\n              <circle cx=\"14\" cy=\"21\" r=\"5\" />\n              <circle cx=\"22\" cy=\"19\" r=\"6\" />\n              <rect x=\"10\" y=\"20\" width=\"20\" height=\"6\" />\n            </g>\n            <circle cx=\"28\" cy=\"20\" r=\"6.5\" />\n            <circle cx=\"35\" cy=\"22\" r=\"5\" />\n            <circle cx=\"20\" cy=\"22\" r=\"5.5\" />\n            <rect x=\"18\" y=\"20\" width=\"22\" height=\"8\" />\n          </svg>\n        </span>\n        <span className=\"hb-qn1-thumb\" aria-hidden=\"true\">\n          <svg className=\"hb-qn1-svg\" viewBox=\"0 0 24 24\" focusable=\"false\">\n            <g className=\"hb-qn1-rays\">\n              {[0, 45, 90, 135, 180, 225, 270, 315].map((deg) => (\n                <line key={deg} x1=\"12\" y1=\"0.8\" x2=\"12\" y2=\"2.8\" transform={`rotate(${deg} 12 12)`} />\n              ))}\n            </g>\n            <mask id={maskId} maskUnits=\"userSpaceOnUse\" x=\"-6\" y=\"-6\" width=\"36\" height=\"36\">\n              <rect x=\"-6\" y=\"-6\" width=\"36\" height=\"36\" fill=\"#fff\" />\n              <circle className=\"hb-qn1-cut\" cx=\"17.5\" cy=\"8\" r=\"6.4\" fill=\"#000\" />\n            </mask>\n            <g mask={`url(#${maskId})`}>\n              <circle className=\"hb-qn1-core\" cx=\"12\" cy=\"12\" r=\"6.2\" />\n              <circle className=\"hb-qn1-crater\" cx=\"8.6\" cy=\"13.4\" r=\"1.3\" />\n              <circle className=\"hb-qn1-crater\" cx=\"11.4\" cy=\"16.6\" r=\"0.9\" />\n              <circle className=\"hb-qn1-crater\" cx=\"7.6\" cy=\"10.2\" r=\"0.8\" />\n            </g>\n          </svg>\n        </span>\n      </label>\n    </>\n  );\n}\n"
    }
  ]
}