{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"theme-switchers","type":"registry:component","title":"Theme switchers","description":"Three appearance controls — a light/dark/system segmented switch with a sliding thumb, an appearance card with live mini previews, and an accent and density picker — that report changes without touching your site.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/theme-switchers/segmented.tsx","type":"registry:component","target":"components/examples/theme-switchers/segmented.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/react\";\nimport { Monitor, Moon, Sun } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ThemeChoice = \"light\" | \"dark\" | \"system\";\n\nexport interface ThemeSegmentedProps {\n  value?: ThemeChoice;\n  defaultValue?: ThemeChoice;\n  /** Fires with the new choice. Nothing on the page changes unless you apply it. */\n  onChange?: (theme: ThemeChoice) => void;\n  /** Icons only, for toolbars. */\n  iconOnly?: boolean;\n  size?: \"sm\" | \"md\";\n  className?: string;\n}\n\nconst OPTIONS = [\n  { id: \"light\", label: \"Light\", Icon: Sun },\n  { id: \"dark\", label: \"Dark\", Icon: Moon },\n  { id: \"system\", label: \"System\", Icon: Monitor },\n] as const;\nconst spring = { type: \"spring\", stiffness: 460, damping: 34 } as const;\n\n/** Light / dark / system radio group with a thumb that slides between options and an icon that turns as it lands. */\nexport function ThemeSegmented({ value, defaultValue = \"system\", onChange, iconOnly = false, size = \"md\", className }: ThemeSegmentedProps) {\n  const uid = React.useId();\n  const [inner, setInner] = React.useState<ThemeChoice>(defaultValue);\n  const current = value ?? inner;\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n\n  function choose(id: ThemeChoice, focus = false) {\n    if (value === undefined) setInner(id);\n    onChange?.(id);\n    if (focus) refs.current[OPTIONS.findIndex((o) => o.id === id)]?.focus();\n  }\n\n  function onKey(e: React.KeyboardEvent) {\n    const i = OPTIONS.findIndex((o) => o.id === current);\n    const n = OPTIONS.length;\n    const map: Record<string, number> = { ArrowRight: (i + 1) % n, ArrowDown: (i + 1) % n, ArrowLeft: (i - 1 + n) % n, ArrowUp: (i - 1 + n) % n, Home: 0, End: n - 1 };\n    if (!(e.key in map)) return;\n    e.preventDefault();\n    choose(OPTIONS[map[e.key]].id, true);\n  }\n\n  const sm = size === \"sm\";\n\n  return (\n    <div role=\"radiogroup\" aria-label=\"Theme\" onKeyDown={onKey} className={cn(\"inline-flex rounded-full border border-border bg-surface-sunken p-1\", className)}>\n      {OPTIONS.map(({ id, label, Icon }, i) => {\n        const on = current === id;\n        return (\n          <motion.button\n            key={id}\n            ref={(el) => {\n              refs.current[i] = el;\n            }}\n            type=\"button\"\n            role=\"radio\"\n            aria-checked={on}\n            aria-label={iconOnly ? label : undefined}\n            tabIndex={on ? 0 : -1}\n            whileTap={{ scale: 0.94 }}\n            onClick={() => choose(id)}\n            className={cn(\n              \"relative flex items-center justify-center gap-1.5 rounded-full font-medium outline-none transition-colors focus-visible:shadow-[var(--focus-ring)]\",\n              sm ? \"h-7 text-[12px]\" : \"h-9 text-[13px]\",\n              iconOnly ? (sm ? \"w-7\" : \"w-9\") : sm ? \"px-2.5\" : \"px-3.5\",\n              on ? \"text-ink\" : \"text-ink-subtle hover:text-ink\",\n            )}\n          >\n            {on && <motion.span layoutId={`${uid}-thumb`} transition={spring} className=\"absolute inset-0 rounded-full border border-border bg-surface-raised shadow-sm\" />}\n            <motion.span className=\"relative\" animate={{ rotate: on ? (id === \"light\" ? 90 : id === \"dark\" ? -20 : 0) : 0 }} transition={spring}>\n              <Icon aria-hidden className={sm ? \"size-3.5\" : \"size-4\"} />\n            </motion.span>\n            {!iconOnly && <span className=\"relative\">{label}</span>}\n          </motion.button>\n        );\n      })}\n    </div>\n  );\n}\n"},{"path":"registry/geturui/examples/theme-switchers/appearance-card.tsx","type":"registry:component","target":"components/examples/theme-switchers/appearance-card.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Check } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type AppearanceTheme = \"light\" | \"dark\" | \"system\";\n\nexport interface AppearanceSettings {\n  theme: AppearanceTheme;\n  /** Interface text scale in percent. */\n  textSize: number;\n}\n\nexport interface AppearanceCardProps {\n  defaultValue?: AppearanceSettings;\n  /** Fires with every change. The card only previews; apply the result yourself. */\n  onChange?: (value: AppearanceSettings) => void;\n  className?: string;\n}\n\nconst THEMES = [\n  { id: \"light\", label: \"Light\" },\n  { id: \"dark\", label: \"Dark\" },\n  { id: \"system\", label: \"System\" },\n] as const;\nconst SIZES = [90, 100, 110, 125];\nconst DEFAULT: AppearanceSettings = { theme: \"dark\", textSize: 100 };\nconst spring = { type: \"spring\", stiffness: 420, damping: 30 } as const;\n\n/** A tiny app window drawn with tokens, scoped to one theme with data-theme. */\nfunction Mini({ scheme }: { scheme: \"light\" | \"dark\" }) {\n  return (\n    <div data-theme={scheme} className=\"flex h-full w-full gap-1.5 bg-bg p-2\">\n      <div className=\"flex w-1/4 flex-col gap-1 rounded-[4px] bg-surface p-1\">\n        <span className=\"h-1.5 w-full rounded-full bg-volt\" />\n        <span className=\"h-1 w-3/4 rounded-full bg-ink-subtle/50\" />\n        <span className=\"h-1 w-2/3 rounded-full bg-ink-subtle/50\" />\n      </div>\n      <div className=\"flex flex-1 flex-col gap-1 rounded-[4px] border border-border bg-surface-raised p-1.5\">\n        <span className=\"h-1.5 w-2/3 rounded-full bg-ink\" />\n        <span className=\"h-1 w-full rounded-full bg-ink-subtle/40\" />\n        <span className=\"h-1 w-5/6 rounded-full bg-ink-subtle/40\" />\n        <span className=\"mt-auto h-2.5 w-8 rounded-full bg-volt\" />\n      </div>\n    </div>\n  );\n}\n\n/** Appearance settings with mini window previews for each theme, a springing check on the chosen one and a live text-size sample. */\nexport function AppearanceCard({ defaultValue = DEFAULT, onChange, className }: AppearanceCardProps) {\n  const reduce = useReducedMotion();\n  const uid = React.useId();\n  const [value, setValue] = React.useState(defaultValue);\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n\n  function update(next: Partial<AppearanceSettings>) {\n    const v = { ...value, ...next };\n    setValue(v);\n    onChange?.(v);\n  }\n\n  function onKey(e: React.KeyboardEvent) {\n    const i = THEMES.findIndex((t) => t.id === value.theme);\n    const step = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 0;\n    if (!step) return;\n    e.preventDefault();\n    const n = (i + step + THEMES.length) % THEMES.length;\n    update({ theme: THEMES[n].id });\n    refs.current[n]?.focus();\n  }\n\n  const sizeIndex = SIZES.indexOf(value.textSize);\n\n  return (\n    <section aria-labelledby={`${uid}-t`} className={cn(\"w-full max-w-[520px] rounded-lg border border-border bg-surface-raised p-5 shadow-sm\", className)}>\n      <h2 id={`${uid}-t`} className=\"font-display text-[16px] font-semibold text-ink\">Appearance</h2>\n      <p className=\"mt-0.5 text-[12.5px] text-ink-muted\">Choose how the workspace looks on this device.</p>\n\n      <div role=\"radiogroup\" aria-label=\"Theme\" onKeyDown={onKey} className=\"mt-4 grid grid-cols-3 gap-2.5 sm:gap-3\">\n        {THEMES.map(({ id, label }, i) => {\n          const on = value.theme === id;\n          return (\n            <motion.button\n              key={id}\n              ref={(el) => {\n                refs.current[i] = el;\n              }}\n              type=\"button\"\n              role=\"radio\"\n              aria-checked={on}\n              tabIndex={on ? 0 : -1}\n              whileTap={{ scale: 0.97 }}\n              onClick={() => update({ theme: id })}\n              className=\"group flex flex-col gap-2 rounded-md text-left outline-none focus-visible:shadow-[var(--focus-ring)]\"\n            >\n              <span className={cn(\"relative block aspect-[4/3] w-full overflow-hidden rounded-md border-2 transition-colors\", on ? \"border-volt-ink\" : \"border-border group-hover:border-border-strong\")}>\n                {id === \"system\" ? (\n                  <>\n                    <span className=\"absolute inset-0\"><Mini scheme=\"light\" /></span>\n                    <span className=\"absolute inset-0 [clip-path:polygon(100%_0,100%_100%,0_100%)]\"><Mini scheme=\"dark\" /></span>\n                  </>\n                ) : (\n                  <Mini scheme={id} />\n                )}\n                <AnimatePresence>\n                  {on && (\n                    <motion.span initial={{ scale: 0, rotate: reduce ? 0 : -30 }} animate={{ scale: 1, rotate: 0 }} exit={{ scale: 0 }} transition={{ type: \"spring\", stiffness: 520, damping: 18 }} className=\"absolute right-1.5 top-1.5 grid size-5 place-items-center rounded-full bg-volt text-on-volt shadow-sm\">\n                      <Check aria-hidden className=\"size-3\" strokeWidth={3} />\n                    </motion.span>\n                  )}\n                </AnimatePresence>\n              </span>\n              <span className={cn(\"px-0.5 text-[12.5px] font-medium\", on ? \"text-ink\" : \"text-ink-muted\")}>{label}</span>\n            </motion.button>\n          );\n        })}\n      </div>\n\n      <div className=\"mt-5 border-t border-border pt-4\">\n        <div className=\"flex items-center justify-between\">\n          <label htmlFor={`${uid}-size`} className=\"text-[13px] font-medium text-ink\">Text size</label>\n          <span className=\"font-mono text-[12px] tabular-nums text-ink-muted\">{value.textSize}%</span>\n        </div>\n        <div className=\"mt-3 flex items-center gap-3\">\n          <span aria-hidden className=\"text-[11px] font-semibold text-ink-subtle\">A</span>\n          <div className=\"relative flex-1\">\n            <div className=\"absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-surface-sunken ring-1 ring-border\" />\n            <motion.div className=\"absolute left-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-volt\" animate={{ width: `${(sizeIndex / (SIZES.length - 1)) * 100}%` }} transition={spring} />\n            <div className=\"relative flex justify-between\">\n              {SIZES.map((s, i) => (\n                <span key={s} aria-hidden className={cn(\"size-2 rounded-full\", i <= sizeIndex ? \"bg-volt\" : \"bg-border-strong\")} />\n              ))}\n            </div>\n            <input\n              id={`${uid}-size`}\n              type=\"range\"\n              min={0}\n              max={SIZES.length - 1}\n              step={1}\n              value={sizeIndex}\n              aria-valuetext={`${value.textSize} percent`}\n              onChange={(e) => update({ textSize: SIZES[Number(e.target.value)] })}\n              className=\"peer absolute inset-0 h-full w-full cursor-pointer opacity-0\"\n            />\n            <motion.span\n              aria-hidden\n              className=\"pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-volt bg-surface-raised shadow-md peer-focus-visible:shadow-[var(--focus-ring)]\"\n              animate={{ left: `${(sizeIndex / (SIZES.length - 1)) * 100}%` }}\n              transition={spring}\n            />\n          </div>\n          <span aria-hidden className=\"text-[16px] font-semibold text-ink-subtle\">A</span>\n        </div>\n        <motion.p layout={!reduce} className=\"mt-4 rounded-md border border-border bg-surface-sunken px-3 py-2.5 text-ink-muted\" style={{ fontSize: `${(13 * value.textSize) / 100}px` }}>\n          The quick review is ready. Leave comments by Friday.\n        </motion.p>\n      </div>\n    </section>\n  );\n}\n"},{"path":"registry/geturui/examples/theme-switchers/accent-density.tsx","type":"registry:component","target":"components/examples/theme-switchers/accent-density.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/react\";\nimport { Check, FileText, Folder, Image as ImageIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type Accent = \"volt\" | \"sky\" | \"violet\" | \"rose\" | \"amber\" | \"graphite\";\nexport type Density = \"compact\" | \"default\" | \"comfortable\";\n\nexport interface AccentDensityValue {\n  accent: Accent;\n  density: Density;\n}\n\nexport interface AccentDensityPickerProps {\n  defaultValue?: AccentDensityValue;\n  /** Fires with every change. Only the preview updates; apply it to your app yourself. */\n  onChange?: (value: AccentDensityValue) => void;\n  className?: string;\n}\n\nconst ACCENTS: { id: Accent; label: string; fill: string; text: string; soft: string }[] = [\n  { id: \"volt\", label: \"Volt\", fill: \"bg-volt\", text: \"text-on-volt\", soft: \"bg-volt-soft\" },\n  { id: \"sky\", label: \"Sky\", fill: \"bg-sky-500\", text: \"text-white\", soft: \"bg-sky-500/15\" },\n  { id: \"violet\", label: \"Violet\", fill: \"bg-violet-500\", text: \"text-white\", soft: \"bg-violet-500/15\" },\n  { id: \"rose\", label: \"Rose\", fill: \"bg-rose-500\", text: \"text-white\", soft: \"bg-rose-500/15\" },\n  { id: \"amber\", label: \"Amber\", fill: \"bg-amber-400\", text: \"text-neutral-950\", soft: \"bg-amber-400/20\" },\n  { id: \"graphite\", label: \"Graphite\", fill: \"bg-ink\", text: \"text-bg\", soft: \"bg-surface-hover\" },\n];\nconst DENSITIES: { id: Density; label: string; row: string }[] = [\n  { id: \"compact\", label: \"Compact\", row: \"py-1\" },\n  { id: \"default\", label: \"Default\", row: \"py-2\" },\n  { id: \"comfortable\", label: \"Comfortable\", row: \"py-3\" },\n];\nconst FILES = [\n  { name: \"Brand guidelines\", meta: \"12 files\", Icon: Folder },\n  { name: \"Q4 roadmap.pdf\", meta: \"2.4 MB\", Icon: FileText },\n  { name: \"Launch hero.png\", meta: \"860 KB\", Icon: ImageIcon },\n];\nconst DEFAULT: AccentDensityValue = { accent: \"volt\", density: \"default\" };\nconst spring = { type: \"spring\", stiffness: 420, damping: 32 } as const;\n\n/** Accent colour and density picker with a live preview: rows re-space with a layout spring and the accent repaints the selection. */\nexport function AccentDensityPicker({ defaultValue = DEFAULT, onChange, className }: AccentDensityPickerProps) {\n  const uid = React.useId();\n  const [value, setValue] = React.useState(defaultValue);\n  const accentRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const densityRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const A = ACCENTS.find((a) => a.id === value.accent) ?? ACCENTS[0];\n  const D = DENSITIES.find((d) => d.id === value.density) ?? DENSITIES[1];\n\n  function update(next: Partial<AccentDensityValue>) {\n    const v = { ...value, ...next };\n    setValue(v);\n    onChange?.(v);\n  }\n\n  function roving<T extends { id: string }>(e: React.KeyboardEvent, list: T[], current: string, refs: React.RefObject<(HTMLButtonElement | null)[]>, pick: (id: T[\"id\"]) => void) {\n    const i = list.findIndex((x) => x.id === current);\n    const step = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 0;\n    if (!step) return;\n    e.preventDefault();\n    const n = (i + step + list.length) % list.length;\n    pick(list[n].id);\n    refs.current[n]?.focus();\n  }\n\n  return (\n    <section aria-labelledby={`${uid}-t`} className={cn(\"grid w-full max-w-[640px] overflow-hidden rounded-lg border border-border bg-surface-raised shadow-sm sm:grid-cols-[1fr_260px]\", className)}>\n      <div className=\"space-y-5 p-5\">\n        <div>\n          <h2 id={`${uid}-t`} className=\"font-display text-[16px] font-semibold text-ink\">Theme</h2>\n          <p className=\"mt-0.5 text-[12.5px] text-ink-muted\">Pick an accent and how much room things get.</p>\n        </div>\n        <div>\n          <p id={`${uid}-a`} className=\"text-[12px] font-medium text-ink-muted\">Accent · <span className=\"text-ink\">{A.label}</span></p>\n          <div role=\"radiogroup\" aria-labelledby={`${uid}-a`} onKeyDown={(e) => roving(e, ACCENTS, value.accent, accentRefs, (id) => update({ accent: id }))} className=\"mt-2.5 flex flex-wrap gap-2.5\">\n            {ACCENTS.map((a, i) => {\n              const on = a.id === value.accent;\n              return (\n                <motion.button\n                  key={a.id}\n                  ref={(el) => {\n                    accentRefs.current[i] = el;\n                  }}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={on}\n                  aria-label={a.label}\n                  tabIndex={on ? 0 : -1}\n                  whileTap={{ scale: 0.88 }}\n                  onClick={() => update({ accent: a.id })}\n                  className={cn(\"relative grid size-8 place-items-center rounded-full outline-none ring-offset-2 ring-offset-surface-raised transition-shadow focus-visible:shadow-[var(--focus-ring)]\", on && \"ring-2 ring-border-strong\")}\n                >\n                  <span className={cn(\"absolute inset-0 rounded-full shadow-sm ring-1 ring-inset ring-border\", a.fill)} />\n                  {on && (\n                    <motion.span initial={{ scale: 0 }} animate={{ scale: 1 }} transition={{ type: \"spring\", stiffness: 600, damping: 20 }} className={cn(\"relative\", a.text)}>\n                      <Check aria-hidden className=\"size-4\" strokeWidth={3} />\n                    </motion.span>\n                  )}\n                </motion.button>\n              );\n            })}\n          </div>\n        </div>\n        <div>\n          <p id={`${uid}-d`} className=\"text-[12px] font-medium text-ink-muted\">Density</p>\n          <div role=\"radiogroup\" aria-labelledby={`${uid}-d`} onKeyDown={(e) => roving(e, DENSITIES, value.density, densityRefs, (id) => update({ density: id }))} className=\"mt-2.5 grid grid-cols-3 rounded-full border border-border bg-surface-sunken p-1\">\n            {DENSITIES.map((d, i) => {\n              const on = d.id === value.density;\n              return (\n                <button\n                  key={d.id}\n                  ref={(el) => {\n                    densityRefs.current[i] = el;\n                  }}\n                  type=\"button\"\n                  role=\"radio\"\n                  aria-checked={on}\n                  tabIndex={on ? 0 : -1}\n                  onClick={() => update({ density: d.id })}\n                  className={cn(\"relative h-8 rounded-full text-[12.5px] font-medium outline-none focus-visible:shadow-[var(--focus-ring)]\", on ? \"text-ink\" : \"text-ink-subtle hover:text-ink\")}\n                >\n                  {on && <motion.span layoutId={`${uid}-den`} transition={spring} className=\"absolute inset-0 rounded-full border border-border bg-surface-raised shadow-sm\" />}\n                  <span className=\"relative\">{d.label}</span>\n                </button>\n              );\n            })}\n          </div>\n        </div>\n      </div>\n\n      <div aria-label=\"Preview\" role=\"img\" className=\"border-t border-border bg-surface p-4 sm:border-l sm:border-t-0\">\n        <p className=\"text-[11px] font-medium uppercase tracking-wide text-ink-subtle\">Preview</p>\n        <motion.ul layout className=\"mt-2.5 rounded-md border border-border bg-surface-raised p-1\">\n          {FILES.map(({ name, meta, Icon }, i) => (\n            <motion.li key={name} layout transition={spring} className={cn(\"relative flex items-center gap-2.5 rounded-sm px-2\", D.row)}>\n              {i === 1 && <motion.span layout transition={spring} className={cn(\"absolute inset-0 rounded-sm\", A.soft)} />}\n              <Icon aria-hidden className={cn(\"relative size-4\", i === 1 ? \"text-ink\" : \"text-ink-subtle\")} />\n              <span className=\"relative flex-1 truncate text-[12.5px] text-ink\">{name}</span>\n              <span className=\"relative text-[11px] text-ink-subtle\">{meta}</span>\n            </motion.li>\n          ))}\n        </motion.ul>\n        <motion.div layout transition={spring} className=\"mt-3\">\n          <div className=\"flex justify-between text-[11px] text-ink-muted\">\n            <span>Storage</span>\n            <span className=\"tabular-nums\">68%</span>\n          </div>\n          <div className=\"mt-1.5 h-1.5 overflow-hidden rounded-full bg-border\">\n            <motion.div layout className={cn(\"h-full w-[68%] rounded-full transition-colors duration-300\", A.fill)} />\n          </div>\n        </motion.div>\n        <motion.div layout transition={spring} className={cn(\"mt-3 grid h-8 place-items-center rounded-full text-[12.5px] font-semibold transition-colors duration-300\", A.fill, A.text)}>\n          Share folder\n        </motion.div>\n      </div>\n    </section>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","theme","dark mode","light mode","appearance","accent","density","segmented control","settings"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/theme-switchers"}}