{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-screen",
  "title": "Settings Screen",
  "description": "A settings page with section navigation (Profile, Workspace, Appearance, Danger zone), labelled form rows with validation, theme cards, accent colours and density, an unsaved-changes bar that slides up with Discard and Save, dots on sections with pending edits, and a typed confirmation before deleting the workspace.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/settings-screen/settings-screen.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface SettingsValues {\n  name: string;\n  email: string;\n  bio: string;\n  workspace: string;\n  slug: string;\n  timezone: string;\n  language: string;\n  appearance: \"light\" | \"dark\" | \"system\";\n  accent: string;\n  density: \"comfortable\" | \"compact\";\n}\n\nexport interface SettingsScreenProps {\n  values?: SettingsValues;\n  onSave?: (values: SettingsValues) => Promise<void> | void;\n  onDeleteWorkspace?: () => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", card: \"#121212\", nav: \"#0F0F0F\", border: \"rgba(255,255,255,0.09)\", chip: \"rgba(255,255,255,0.06)\", hover: \"rgba(255,255,255,0.04)\", input: \"#0D0D0D\", on: \"#F5F4F1\", onText: \"#0A0A0A\", red: \"#F87171\", green: \"#4ADE80\", ring: \"rgba(245,244,241,0.6)\", bar: \"#1A1A1A\", shadow: \"0 20px 50px -16px rgba(0,0,0,0.8)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", nav: \"#FAFAF8\", border: \"rgba(10,10,10,0.09)\", chip: \"rgba(10,10,10,0.05)\", hover: \"rgba(10,10,10,0.03)\", input: \"#FAFAF8\", on: \"#0A0A0A\", onText: \"#FAFAF8\", red: \"#DC2626\", green: \"#15803D\", ring: \"rgba(10,10,10,0.5)\", bar: \"#0A0A0A\", shadow: \"0 20px 50px -20px rgba(0,0,0,0.3)\" },\n};\nconst ACCENTS = [\"#FB923C\", \"#F472B6\", \"#A78BFA\", \"#60A5FA\", \"#2DD4BF\", \"#4ADE80\"];\nconst DEFAULT_VALUES: SettingsValues = { name: \"Mara Okafor\", email: \"mara@nexora.io\", bio: \"Head of product. Coffee, maps and tidy spreadsheets.\", workspace: \"Nexora\", slug: \"nexora\", timezone: \"Europe/Berlin\", language: \"English\", appearance: \"dark\", accent: \"#FB923C\", density: \"comfortable\" };\nconst SECTIONS = [\n  { id: \"profile\", label: \"Profile\", hint: \"Your name and photo\" },\n  { id: \"workspace\", label: \"Workspace\", hint: \"Name, address, region\" },\n  { id: \"appearance\", label: \"Appearance\", hint: \"Theme and density\" },\n  { id: \"danger\", label: \"Danger zone\", hint: \"Delete the workspace\" },\n] as const;\ntype Section = (typeof SECTIONS)[number][\"id\"];\n\nexport function SettingsScreen({ values = DEFAULT_VALUES, onSave, onDeleteWorkspace, theme = \"dark\", className }: SettingsScreenProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [saved, setSaved] = React.useState(values);\n  const [form, setForm] = React.useState(values);\n  const [section, setSection] = React.useState<Section>(\"profile\");\n  const [saving, setSaving] = React.useState(false);\n  const [toast, setToast] = React.useState<string | null>(null);\n  const [confirmText, setConfirmText] = React.useState(\"\");\n  const [shake, setShake] = React.useState(0);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  React.useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  const dirtyKeys = (Object.keys(form) as (keyof SettingsValues)[]).filter((k) => form[k] !== saved[k]);\n  const dirty = dirtyKeys.length > 0;\n  const emailOk = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(form.email);\n  const nameOk = form.name.trim().length > 1;\n  const set = <K extends keyof SettingsValues>(k: K, v: SettingsValues[K]) => setForm((f) => ({ ...f, [k]: v }));\n  const save = async () => {\n    if (!emailOk || !nameOk) {\n      setShake((s) => s + 1);\n      return;\n    }\n    setSaving(true);\n    if (onSave) await onSave(form);\n    else await new Promise((r) => setTimeout(r, reduce ? 100 : 700));\n    setSaving(false);\n    setSaved(form);\n    setToast(\"Settings saved\");\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setToast(null), 2000);\n  };\n  const go = (s: Section) => {\n    setSection(s);\n    setConfirmText(\"\");\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const field = cn(\"h-10 w-full rounded-lg border px-3 text-[14px]\", focus);\n  const fs = (bad?: boolean) => ({ borderColor: bad ? p.red : p.border, background: p.input, color: p.text, ...ring }) as React.CSSProperties;\n  const row = (label: string, hint: string, control: React.ReactNode, id?: string) => (\n    <div className=\"grid gap-2 border-t py-5 first:border-t-0 first:pt-0 @[720px]:grid-cols-[220px_1fr] @[720px]:gap-6\" style={{ borderColor: p.border }}>\n      <div>\n        <label htmlFor={id} className=\"block text-[13.5px] font-medium\">\n          {label}\n        </label>\n        <p className=\"m-0 mt-0.5 text-[12.5px]\" style={{ color: p.faint }}>\n          {hint}\n        </p>\n      </div>\n      <div className=\"min-w-0\">{control}</div>\n    </div>\n  );\n\n  const panels: Record<Section, React.ReactNode> = {\n    profile: (\n      <>\n        {row(\n          \"Photo\",\n          \"PNG or JPG, at least 256px.\",\n          <div className=\"flex items-center gap-4\">\n            {/* eslint-disable-next-line @next/next/no-img-element */}\n            <img src=\"/demo/44.webp\" alt=\"\" className=\"h-14 w-14 rounded-full object-cover\" />\n            <button type=\"button\" className={cn(\"h-9 cursor-pointer rounded-lg border bg-transparent px-3 text-[13px]\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n              Change photo\n            </button>\n            <button type=\"button\" className={cn(\"h-9 cursor-pointer rounded-lg border-0 bg-transparent px-2 text-[13px]\", focus)} style={{ color: p.muted, ...ring }}>\n              Remove\n            </button>\n          </div>,\n        )}\n        {row(\n          \"Full name\",\n          \"Shown on comments and mentions.\",\n          <>\n            <input id={`${uid}-name`} value={form.name} onChange={(e) => set(\"name\", e.target.value)} aria-invalid={!nameOk} className={field} style={fs(!nameOk)} />\n            {!nameOk && (\n              <p className=\"m-0 mt-1.5 text-[12px]\" style={{ color: p.red }} role=\"alert\">\n                Enter your name.\n              </p>\n            )}\n          </>,\n          `${uid}-name`,\n        )}\n        {row(\n          \"Email\",\n          \"We send sign-in links and receipts here.\",\n          <>\n            <input id={`${uid}-email`} type=\"email\" value={form.email} onChange={(e) => set(\"email\", e.target.value)} aria-invalid={!emailOk} className={field} style={fs(!emailOk)} />\n            {!emailOk && (\n              <p className=\"m-0 mt-1.5 text-[12px]\" style={{ color: p.red }} role=\"alert\">\n                That doesn&apos;t look like an email address.\n              </p>\n            )}\n          </>,\n          `${uid}-email`,\n        )}\n        {row(\n          \"Bio\",\n          \"A line about you for your teammates.\",\n          <>\n            <textarea id={`${uid}-bio`} rows={3} maxLength={160} value={form.bio} onChange={(e) => set(\"bio\", e.target.value)} className={cn(\"w-full resize-none rounded-lg border px-3 py-2 text-[14px]\", focus)} style={fs()} />\n            <p className=\"m-0 mt-1 text-right text-[11.5px] tabular-nums\" style={{ color: form.bio.length > 140 ? p.red : p.faint }}>\n              {form.bio.length}/160\n            </p>\n          </>,\n          `${uid}-bio`,\n        )}\n      </>\n    ),\n    workspace: (\n      <>\n        {row(\"Workspace name\", \"Visible to everyone in the workspace.\", <input id={`${uid}-ws`} value={form.workspace} onChange={(e) => set(\"workspace\", e.target.value)} className={field} style={fs()} />, `${uid}-ws`)}\n        {row(\n          \"Web address\",\n          \"Changing it breaks old links.\",\n          <div className=\"flex h-10 items-center overflow-hidden rounded-lg border focus-within:ring-2\" style={fs()}>\n            <span className=\"pl-3 text-[14px]\" style={{ color: p.faint }}>\n              nexora.app/\n            </span>\n            <input id={`${uid}-slug`} value={form.slug} onChange={(e) => set(\"slug\", e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, \"\"))} className=\"h-full min-w-0 flex-1 border-0 bg-transparent pr-3 text-[14px] outline-none\" style={{ color: p.text }} />\n          </div>,\n          `${uid}-slug`,\n        )}\n        {row(\n          \"Time zone\",\n          \"Used for due dates and reports.\",\n          <select id={`${uid}-tz`} value={form.timezone} onChange={(e) => set(\"timezone\", e.target.value)} className={cn(field, \"cursor-pointer\")} style={fs()}>\n            {[\"Europe/Berlin\", \"Europe/Istanbul\", \"Europe/London\", \"America/New_York\", \"America/Los_Angeles\", \"Asia/Tokyo\"].map((z) => (\n              <option key={z}>{z}</option>\n            ))}\n          </select>,\n          `${uid}-tz`,\n        )}\n        {row(\n          \"Language\",\n          \"For menus, emails and dates.\",\n          <select id={`${uid}-lang`} value={form.language} onChange={(e) => set(\"language\", e.target.value)} className={cn(field, \"cursor-pointer\")} style={fs()}>\n            {[\"English\", \"Deutsch\", \"Español\", \"Français\", \"Türkçe\", \"日本語\"].map((z) => (\n              <option key={z}>{z}</option>\n            ))}\n          </select>,\n          `${uid}-lang`,\n        )}\n      </>\n    ),\n    appearance: (\n      <>\n        {row(\n          \"Theme\",\n          \"Follow your system or pick one.\",\n          <div role=\"radiogroup\" aria-label=\"Theme\" className=\"grid grid-cols-3 gap-2.5\">\n            {([\"light\", \"dark\", \"system\"] as const).map((m) => {\n              const on = form.appearance === m;\n              return (\n                <button key={m} type=\"button\" role=\"radio\" aria-checked={on} onClick={() => set(\"appearance\", m)} className={cn(\"cursor-pointer rounded-xl border bg-transparent p-2 text-left\", focus)} style={{ borderColor: on ? form.accent : p.border, color: p.text, ...ring }}>\n                  <span className=\"block h-14 overflow-hidden rounded-lg\" style={{ background: m === \"light\" ? \"#F4F4F1\" : m === \"dark\" ? \"#141414\" : \"linear-gradient(90deg,#F4F4F1 50%,#141414 50%)\" }} aria-hidden=\"true\">\n                    <span className=\"mt-2.5 ml-2.5 block h-1.5 w-10 rounded-full\" style={{ background: form.accent }} />\n                    <span className=\"mt-1.5 ml-2.5 block h-1.5 w-14 rounded-full\" style={{ background: m === \"dark\" ? \"#333\" : \"#CFCFCA\" }} />\n                  </span>\n                  <span className=\"mt-2 flex items-center gap-1.5 px-0.5 text-[12.5px] capitalize\">\n                    <span className=\"flex h-3.5 w-3.5 items-center justify-center rounded-full border\" style={{ borderColor: on ? form.accent : p.faint }}>\n                      {on && <motion.span layoutId={reduce ? undefined : `${uid}-theme`} className=\"h-2 w-2 rounded-full\" style={{ background: form.accent }} />}\n                    </span>\n                    {m}\n                  </span>\n                </button>\n              );\n            })}\n          </div>,\n        )}\n        {row(\n          \"Accent colour\",\n          \"Buttons, links and highlights.\",\n          <div role=\"radiogroup\" aria-label=\"Accent colour\" className=\"flex flex-wrap gap-2.5\">\n            {ACCENTS.map((a) => {\n              const on = form.accent === a;\n              return (\n                <button key={a} type=\"button\" role=\"radio\" aria-checked={on} aria-label={a} onClick={() => set(\"accent\", a)} className={cn(\"relative flex h-8 w-8 cursor-pointer items-center justify-center rounded-full border-0\", focus)} style={{ background: a, ...ring }}>\n                  <AnimatePresence>\n                    {on && (\n                      <motion.svg initial={reduce ? false : { scale: 0 }} animate={{ scale: 1 }} exit={reduce ? undefined : { scale: 0 }} width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"#0A0A0A\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                        <path d=\"m3 8.5 3 3 7-7\" />\n                      </motion.svg>\n                    )}\n                  </AnimatePresence>\n                </button>\n              );\n            })}\n          </div>,\n        )}\n        {row(\n          \"Density\",\n          \"How much fits on screen.\",\n          <div role=\"radiogroup\" aria-label=\"Density\" className=\"flex w-fit rounded-lg border p-0.5\" style={{ borderColor: p.border }}>\n            {([\"comfortable\", \"compact\"] as const).map((d) => (\n              <button key={d} type=\"button\" role=\"radio\" aria-checked={form.density === d} onClick={() => set(\"density\", d)} className={cn(\"relative h-8 cursor-pointer rounded-md border-0 bg-transparent px-3.5 text-[13px] capitalize\", focus)} style={{ color: form.density === d ? p.text : p.faint, ...ring }}>\n                {form.density === d && <motion.span layoutId={`${uid}-dens`} className=\"absolute inset-0 rounded-md\" style={{ background: p.chip }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 38 }} />}\n                <span className=\"relative\">{d}</span>\n              </button>\n            ))}\n          </div>,\n        )}\n      </>\n    ),\n    danger: (\n      <div className=\"rounded-xl border p-5\" style={{ borderColor: p.red }}>\n        <h3 className=\"m-0 text-[15px] font-semibold\" style={{ color: p.red }}>\n          Delete workspace\n        </h3>\n        <p className=\"m-0 mt-1.5 text-[13.5px] leading-[1.6]\" style={{ color: p.muted }}>\n          This deletes {saved.workspace}, its projects, files and history for everyone. It cannot be undone. Type <span className=\"font-mono font-semibold\" style={{ color: p.text }}>{saved.slug}</span> to confirm.\n        </p>\n        <div className=\"mt-4 flex flex-col gap-2 @[560px]:flex-row\">\n          <label htmlFor={`${uid}-confirm`} className=\"sr-only\">\n            Type {saved.slug} to confirm\n          </label>\n          <input id={`${uid}-confirm`} value={confirmText} onChange={(e) => setConfirmText(e.target.value)} placeholder={saved.slug} autoComplete=\"off\" className={cn(field, \"font-mono @[560px]:max-w-xs\")} style={fs()} />\n          <button type=\"button\" disabled={confirmText !== saved.slug} onClick={() => onDeleteWorkspace?.()} className={cn(\"h-10 cursor-pointer rounded-lg border-0 px-4 text-[13.5px] font-medium disabled:cursor-not-allowed disabled:opacity-40\", focus)} style={{ background: p.red, color: \"#fff\", ...ring }}>\n            Delete workspace\n          </button>\n        </div>\n      </div>\n    ),\n  };\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"relative mx-auto max-w-5xl px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        <div className=\"relative grid min-h-[600px] grid-cols-[minmax(0,1fr)] overflow-hidden rounded-2xl border @[760px]:grid-cols-[230px_minmax(0,1fr)]\" style={{ background: p.card, borderColor: p.border }}>\n          <nav aria-label=\"Settings\" className=\"border-b p-4 @[760px]:border-r @[760px]:border-b-0 @[760px]:p-5\" style={{ background: p.nav, borderColor: p.border }}>\n            <h2 className=\"m-0 mb-3 text-[18px] font-semibold tracking-[-0.01em] @[760px]:mb-5\">Settings</h2>\n            <ul className=\"m-0 flex list-none gap-1 overflow-x-auto p-0 @[760px]:flex-col\">\n              {SECTIONS.map((s) => {\n                const on = section === s.id;\n                const has = s.id === \"profile\" ? [\"name\", \"email\", \"bio\"].some((k) => dirtyKeys.includes(k as keyof SettingsValues)) : s.id === \"workspace\" ? [\"workspace\", \"slug\", \"timezone\", \"language\"].some((k) => dirtyKeys.includes(k as keyof SettingsValues)) : s.id === \"appearance\" ? [\"appearance\", \"accent\", \"density\"].some((k) => dirtyKeys.includes(k as keyof SettingsValues)) : false;\n                return (\n                  <li key={s.id} className=\"shrink-0\">\n                    <button type=\"button\" aria-current={on ? \"page\" : undefined} onClick={() => go(s.id)} className={cn(\"relative flex w-full cursor-pointer items-center gap-2 rounded-lg border-0 bg-transparent px-3 py-2 text-left\", focus)} style={{ color: on ? p.text : s.id === \"danger\" ? p.red : p.muted, ...ring }}>\n                      {on && <motion.span layoutId={`${uid}-sec`} className=\"absolute inset-0 rounded-lg\" style={{ background: p.chip }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 38 }} />}\n                      <span className=\"relative min-w-0 flex-1\">\n                        <span className=\"block text-[13.5px] font-medium whitespace-nowrap\">{s.label}</span>\n                        <span className=\"hidden text-[11.5px] @[760px]:block\" style={{ color: p.faint }}>\n                          {s.hint}\n                        </span>\n                      </span>\n                      {has && <span className=\"relative h-1.5 w-1.5 rounded-full\" style={{ background: form.accent }} aria-label=\"Unsaved changes\" />}\n                    </button>\n                  </li>\n                );\n              })}\n            </ul>\n          </nav>\n\n          <div className=\"min-w-0 p-5 pb-24 @[640px]:p-7 @[640px]:pb-24\">\n            <AnimatePresence mode=\"wait\" initial={false}>\n              <motion.div key={section} initial={reduce ? false : { opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} transition={{ duration: 0.16 }}>\n                <h3 className=\"m-0 text-[17px] font-semibold tracking-[-0.01em]\">\n                  {SECTIONS.find((s) => s.id === section)?.label}\n                </h3>\n                <p className=\"m-0 mt-1 mb-6 text-[13px]\" style={{ color: p.muted }}>\n                  {SECTIONS.find((s) => s.id === section)?.hint}.\n                </p>\n                {panels[section]}\n              </motion.div>\n            </AnimatePresence>\n          </div>\n\n          {/* Unsaved changes bar */}\n          <AnimatePresence>\n            {dirty && (\n              <motion.div initial={reduce ? false : { y: 80, opacity: 0 }} animate={{ y: 0, opacity: 1 }} exit={reduce ? undefined : { y: 80, opacity: 0 }} transition={{ type: \"spring\", stiffness: 420, damping: 34 }} className=\"absolute inset-x-3 bottom-3 z-20 @[760px]:left-[248px]\" role=\"region\" aria-label=\"Unsaved changes\">\n                <motion.div key={shake} initial={{ x: 0 }} animate={shake && !reduce ? { x: [0, -8, 8, -5, 5, 0] } : { x: 0 }} transition={{ duration: 0.4 }} className=\"flex flex-wrap items-center justify-between gap-3 rounded-xl px-4 py-3\" style={{ background: p.bar, color: \"#F5F4F1\", boxShadow: p.shadow }}>\n                <span className=\"text-[13px]\">\n                  {dirtyKeys.length} unsaved {dirtyKeys.length === 1 ? \"change\" : \"changes\"}\n                </span>\n                <span className=\"flex gap-2\">\n                  <button type=\"button\" onClick={() => setForm(saved)} className={cn(\"h-8 cursor-pointer rounded-lg border-0 bg-transparent px-3 text-[13px]\", focus)} style={{ color: \"rgba(245,244,241,0.7)\", ...ring }}>\n                    Discard\n                  </button>\n                  <button type=\"button\" onClick={save} disabled={saving} className={cn(\"flex h-8 cursor-pointer items-center gap-2 rounded-lg border-0 px-3.5 text-[13px] font-medium disabled:cursor-wait\", focus)} style={{ background: form.accent, color: \"#0A0A0A\", ...ring }}>\n                    {saving && <motion.span className=\"h-3 w-3 rounded-full border-2\" style={{ borderTopColor: \"transparent\", borderRightColor: \"#0A0A0A\", borderBottomColor: \"#0A0A0A\", borderLeftColor: \"#0A0A0A\" }} animate={reduce ? undefined : { rotate: 360 }} transition={{ duration: 0.7, repeat: Infinity, ease: \"linear\" }} aria-hidden=\"true\" />}\n                    {saving ? \"Saving…\" : \"Save changes\"}\n                  </button>\n                </span>\n                </motion.div>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n\n        <div className=\"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center px-4\" aria-live=\"polite\">\n          <AnimatePresence>\n            {toast && (\n              <motion.div initial={reduce ? false : { opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: 6 }} className=\"flex items-center gap-2 rounded-full px-4 py-2 text-[13px] font-medium shadow-lg\" style={{ background: p.on, color: p.onText }}>\n                <svg width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"m3 8.5 3 3 7-7\" />\n                </svg>\n                {toast}\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default SettingsScreen;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}