{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"dark-mode-toggle-light-dark-system-segmented","type":"registry:component","title":"Dark Mode Toggle Light Dark System Segmented","description":"","dependencies":[],"files":[{"path":"components/we-inc/dark-mode-toggle-light-dark-system-segmented.tsx","type":"registry:component","content":"import { useEffect, useState } from \"react\";\n\n// Three-way theme picker built on real radio inputs: Light, Dark or follow the System.\nconst options = [\n  { id: \"light\", label: \"Light\", d: \"M10 6a4 4 0 1 1 0 8 4 4 0 0 1 0-8zM9 1h2v3H9zm0 15h2v3H9zM1 9h3v2H1zm15 0h3v2h-3z\" },\n  { id: \"dark\", label: \"Dark\", d: \"M15.5 13.2A7 7 0 0 1 6.8 4.5 7 7 0 1 0 15.5 13.2z\" },\n  { id: \"system\", label: \"System\", d: \"M2 4h16v10H2zm2 2v6h12V6zM7 16h6v2H7z\" },\n] as const;\ntype Mode = (typeof options)[number][\"id\"];\n\nexport default function DarkModeToggleLightDarkSystemSegmented() {\n  const [mode, setMode] = useState<Mode>(\"system\");\n  const [systemDark, setSystemDark] = useState(false);\n\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-color-scheme: dark)\");\n    setSystemDark(mq.matches);\n    const on = (e: MediaQueryListEvent) => setSystemDark(e.matches);\n    mq.addEventListener(\"change\", on);\n    return () => mq.removeEventListener(\"change\", on);\n  }, []);\n\n  const dark = mode === \"dark\" || (mode === \"system\" && systemDark);\n  return (\n    <section className={`px-5 py-14 ${dark ? \"bg-stone-900\" : \"bg-stone-100\"}`}>\n      <fieldset className={`mx-auto max-w-md rounded-2xl border p-6 ${dark ? \"border-stone-700 bg-stone-800\" : \"border-stone-200 bg-white\"}`}>\n        <legend className=\"sr-only\">Theme</legend>\n        <h2 className={`text-base font-semibold ${dark ? \"text-stone-50\" : \"text-stone-900\"}`} aria-hidden=\"true\">Theme</h2>\n        <p className={`mt-1 text-sm ${dark ? \"text-stone-300\" : \"text-stone-600\"}`}>\n          {mode === \"system\" ? `Following your device, which is ${systemDark ? \"dark\" : \"light\"} right now.` : `Always ${mode}, whatever your device says.`}\n        </p>\n        <div className={`mt-5 grid grid-cols-3 gap-1 rounded-xl p-1 ${dark ? \"bg-stone-900\" : \"bg-stone-100\"}`}>\n          {options.map((o) => (\n            <label key={o.id} className=\"relative\">\n              <input type=\"radio\" name=\"dm2-theme\" value={o.id} checked={mode === o.id} onChange={() => setMode(o.id)} aria-label={o.label} className=\"peer sr-only\" />\n              <span className={`flex min-h-[44px] cursor-pointer items-center justify-center gap-2 rounded-lg text-sm font-medium transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-orange-500 motion-reduce:transition-none ${\n                mode === o.id\n                  ? dark ? \"bg-stone-700 text-white shadow-sm\" : \"bg-white text-stone-900 shadow-sm\"\n                  : dark ? \"text-stone-300 hover:text-white\" : \"text-stone-600 hover:text-stone-900\"\n              }`}>\n                <svg viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" aria-hidden=\"true\" className=\"fill-current\"><path d={o.d} /></svg>\n                {o.label}\n              </span>\n            </label>\n          ))}\n        </div>\n      </fieldset>\n    </section>\n  );\n}\n"}]}
