{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hud-toggle-switch",
  "type": "registry:component",
  "title": "HUD Toggle Switch",
  "description": "A compact labelled switch like SND ON with bracket corners, a status dot and a flash on every click.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hud",
    "toggle",
    "switch",
    "hud",
    "settings",
    "sound",
    "button"
  ],
  "docs": "https://hyperblur.dev/effects/hud-toggle-switch",
  "files": [
    {
      "path": "registry/hyperblur/hud-toggle-switch.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hud-toggle-switch.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HudToggleSwitchProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"onChange\" | \"value\" | \"defaultValue\"> {\n  label?: string;\n  checked?: boolean;\n  defaultChecked?: boolean;\n  onChange?: (checked: boolean) => void;\n  onLabel?: string;\n  offLabel?: string;\n  accent?: string;\n}\n\nconst css = `\n.hb-uaa {\n  --hb-uaa-accent: #ff4d4d;\n  position: relative;\n  box-sizing: border-box;\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  height: 28px;\n  margin: 0;\n  padding: 0 10px;\n  overflow: visible;\n  border: 1px solid rgba(255,255,255,.12);\n  border-radius: 0;\n  background: rgba(255,255,255,.025);\n  color: #a1a1a1;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 10px;\n  letter-spacing: .14em;\n  text-transform: uppercase;\n  white-space: nowrap;\n  cursor: pointer;\n  user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color .2s ease, background-color .2s ease, color .2s ease, transform .1s ease, box-shadow .25s ease;\n}\n.hb-uaa *, .hb-uaa *::before, .hb-uaa *::after { box-sizing: border-box; }\n.hb-uaa:hover { border-color: rgba(255,255,255,.22); color: #ededed; }\n.hb-uaa:active { transform: scale(.96); }\n.hb-uaa:focus-visible { outline: 1px solid #ededed; outline-offset: 3px; }\n.hb-uaa:disabled { opacity: .4; cursor: not-allowed; }\n.hb-uaa::before, .hb-uaa::after {\n  content: \"\";\n  position: absolute;\n  width: 6px;\n  height: 6px;\n  border: 0 solid rgba(255,255,255,.45);\n  pointer-events: none;\n  transition: border-color .2s ease;\n}\n.hb-uaa::before { left: -1px; top: -1px; border-left-width: 1px; border-top-width: 1px; }\n.hb-uaa::after { right: -1px; bottom: -1px; border-right-width: 1px; border-bottom-width: 1px; }\n.hb-uaa[aria-checked=\"true\"] {\n  color: #ededed;\n  border-color: color-mix(in srgb, var(--hb-uaa-accent) 50%, transparent);\n  background: color-mix(in srgb, var(--hb-uaa-accent) 9%, transparent);\n  box-shadow: 0 0 14px -6px var(--hb-uaa-accent);\n}\n.hb-uaa[aria-checked=\"true\"]::before, .hb-uaa[aria-checked=\"true\"]::after { border-color: var(--hb-uaa-accent); }\n.hb-uaa-dot {\n  flex: 0 0 auto;\n  width: 6px;\n  height: 6px;\n  border: 1px solid #5f5f5f;\n  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;\n}\n.hb-uaa[aria-checked=\"true\"] .hb-uaa-dot { background: var(--hb-uaa-accent); border-color: var(--hb-uaa-accent); box-shadow: 0 0 8px var(--hb-uaa-accent); }\n.hb-uaa-sep { width: 1px; height: 10px; background: rgba(255,255,255,.14); }\n.hb-uaa-state { position: relative; display: inline-grid; min-width: 3ch; text-align: left; }\n.hb-uaa-state span { grid-area: 1 / 1; transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1); }\n.hb-uaa-state span:first-child { opacity: 0; transform: translateY(-60%); }\n.hb-uaa[aria-checked=\"true\"] .hb-uaa-state span:first-child { opacity: 1; transform: none; color: var(--hb-uaa-accent); }\n.hb-uaa[aria-checked=\"true\"] .hb-uaa-state span:last-child { opacity: 0; transform: translateY(60%); }\n.hb-uaa-flash {\n  position: absolute;\n  inset: -1px;\n  pointer-events: none;\n  border: 1px solid var(--hb-uaa-accent);\n  opacity: 0;\n  animation: hb-uaa-flash .45s ease-out;\n}\n@keyframes hb-uaa-flash {\n  0% { opacity: .9; transform: scale(1); }\n  100% { opacity: 0; transform: scale(1.18, 1.5); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-uaa, .hb-uaa::before, .hb-uaa::after, .hb-uaa-dot, .hb-uaa-state span { transition: none; }\n  .hb-uaa-flash { display: none; }\n}\n`;\n\nexport function HudToggleSwitch({\n  label = \"Snd\",\n  checked,\n  defaultChecked = true,\n  onChange,\n  onLabel = \"On\",\n  offLabel = \"Off\",\n  accent = \"#ff4d4d\",\n  className,\n  style,\n  onClick,\n  ...rest\n}: HudToggleSwitchProps) {\n  const [inner, setInner] = React.useState(defaultChecked);\n  const [pulse, setPulse] = React.useState(0);\n  const on = checked ?? inner;\n\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      aria-label={`${label} ${on ? onLabel : offLabel}`}\n      className={[\"hb-uaa\", className].filter(Boolean).join(\" \")}\n      style={{ [\"--hb-uaa-accent\" as string]: accent, ...style }}\n      onClick={(e) => {\n        onClick?.(e);\n        if (e.defaultPrevented) return;\n        const next = !on;\n        if (checked === undefined) setInner(next);\n        setPulse((p) => p + 1);\n        onChange?.(next);\n      }}\n      {...rest}\n    >\n      <style href=\"hb-hud-toggle-switch\" precedence=\"default\">{css}</style>\n      <span className=\"hb-uaa-dot\" aria-hidden=\"true\" />\n      <span aria-hidden=\"true\">{label}</span>\n      <span className=\"hb-uaa-sep\" aria-hidden=\"true\" />\n      <span className=\"hb-uaa-state\" aria-hidden=\"true\">\n        <span>{onLabel}</span>\n        <span>{offLabel}</span>\n      </span>\n      {pulse ? <span key={pulse} className=\"hb-uaa-flash\" aria-hidden=\"true\" /> : null}\n    </button>\n  );\n}\n\nexport default HudToggleSwitch;\n"
    }
  ]
}