{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkbox-selection-cards",
  "title": "Checkbox Selection Cards",
  "description": "A multi-select onboarding step built from checkbox cards: priced add-ons with a select-all that shows a mixed state, and topics limited to three that lock the rest and shake when you try a fourth. Choices appear as removable chips in a sticky summary with an animated monthly total and Continue.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/checkbox-selection-cards/checkbox-selection-cards.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } 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 SelectionOption {\n  id: string;\n  title: string;\n  description: string;\n  icon: string; // SVG path\n  price?: number;\n  badge?: string;\n}\nexport interface SelectionGroup {\n  id: string;\n  title: string;\n  hint: string;\n  max?: number;\n  options: SelectionOption[];\n}\n\nexport interface CheckboxSelectionCardsProps {\n  groups?: SelectionGroup[];\n  defaultSelected?: string[];\n  onContinue?: (selected: string[], monthlyTotal: number) => Promise<void> | 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\", sel: \"#171A20\", border: \"rgba(255,255,255,0.09)\", accent: \"#60A5FA\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", amber: \"#FBBF24\", ring: \"rgba(245,244,241,0.6)\", chip: \"rgba(255,255,255,0.06)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.42)\", card: \"#FFFFFF\", sel: \"#F2F6FF\", border: \"rgba(10,10,10,0.1)\", accent: \"#2563EB\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", amber: \"#B45309\", ring: \"rgba(10,10,10,0.5)\", chip: \"rgba(10,10,10,0.05)\" },\n};\n\nconst GROUPS: SelectionGroup[] = [\n  {\n    id: \"addons\",\n    title: \"Add-ons\",\n    hint: \"Billed monthly, cancel any time\",\n    options: [\n      { id: \"analytics\", title: \"Advanced analytics\", description: \"Funnels, cohorts and retention charts.\", icon: \"M4 20V10m6 10V4m6 16v-7m4 7H2\", price: 19 },\n      { id: \"sso\", title: \"Single sign-on\", description: \"SAML and OIDC for your whole team.\", icon: \"M6 11h12v10H6zM8 11V8a4 4 0 0 1 8 0v3\", price: 29, badge: \"Team\" },\n      { id: \"audit\", title: \"Audit log\", description: \"Every change, searchable for a year.\", icon: \"M8 4h11v16H8zM5 8h3M5 12h3M5 16h3M11 9h5M11 13h5\", price: 9 },\n      { id: \"backups\", title: \"Hourly backups\", description: \"Restore to any hour in the last 30 days.\", icon: \"M4 12a8 8 0 1 0 2.3-5.7L4 8.5M4 4v4.5h4.5M12 8v4l3 2\", price: 15 },\n      { id: \"support\", title: \"Priority support\", description: \"Replies within one business hour.\", icon: \"M4 13a8 8 0 0 1 16 0v4a2 2 0 0 1-2 2h-1v-6h3M4 13v4a2 2 0 0 0 2 2h1v-6H4\", price: 39 },\n      { id: \"domains\", title: \"Custom domains\", description: \"Serve your portal from your own domain.\", icon: \"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3Z\", price: 5 },\n    ],\n  },\n  {\n    id: \"topics\",\n    title: \"What will you track?\",\n    hint: \"Pick up to 3 so we can set up your first dashboards\",\n    max: 3,\n    options: [\n      { id: \"revenue\", title: \"Revenue\", description: \"MRR, churn and expansion.\", icon: \"M12 3v18M17 7.5C17 5.6 14.8 4 12 4S7 5.6 7 7.5 9.2 11 12 11s5 1.5 5 3.5S14.8 18 12 18s-5-1.6-5-3.5\" },\n      { id: \"product\", title: \"Product usage\", description: \"Active users and feature adoption.\", icon: \"M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM16.5 13v7M13 16.5h7\" },\n      { id: \"marketing\", title: \"Marketing\", description: \"Campaigns, sources and signups.\", icon: \"M4 10v4l12 5V5L4 10Zm12 0h2a2 2 0 0 1 0 4h-2M7 15l1.5 5\" },\n      { id: \"sales\", title: \"Sales pipeline\", description: \"Deals, stages and win rate.\", icon: \"M3 5h18l-7 8v6l-4-2v-4L3 5Z\" },\n      { id: \"supportq\", title: \"Support queue\", description: \"Tickets, response and resolution time.\", icon: \"M4 5h16v11H8l-4 4V5Z\" },\n      { id: \"ops\", title: \"Operations\", description: \"Uptime, incidents and costs.\", icon: \"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm7.4-3a7.4 7.4 0 0 0-.1-1.2l2-1.6-2-3.4-2.4 1a7.5 7.5 0 0 0-2-1.2L14.5 3h-4l-.4 2.6a7.5 7.5 0 0 0-2 1.2l-2.4-1-2 3.4 2 1.6a7.4 7.4 0 0 0 0 2.4l-2 1.6 2 3.4 2.4-1a7.5 7.5 0 0 0 2 1.2l.4 2.6h4l.4-2.6a7.5 7.5 0 0 0 2-1.2l2.4 1 2-3.4-2-1.6c.1-.4.1-.8.1-1.2Z\" },\n    ],\n  },\n];\n\nexport function CheckboxSelectionCards({ groups = GROUPS, defaultSelected = [\"analytics\", \"revenue\"], onContinue, theme = \"dark\", className }: CheckboxSelectionCardsProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [selected, setSelected] = React.useState<string[]>(defaultSelected);\n  const [limitHit, setLimitHit] = React.useState<string | null>(null);\n  const [status, setStatus] = React.useState<\"idle\" | \"busy\" | \"done\">(\"idle\");\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  const all = groups.flatMap((g) => g.options.map((o) => ({ ...o, group: g })));\n  const total = all.filter((o) => selected.includes(o.id)).reduce((s, o) => s + (o.price ?? 0), 0);\n  const mv = useMotionValue(total);\n  const shown = useTransform(mv, (x) => `$${Math.round(x)}`);\n  React.useEffect(() => {\n    const c = animate(mv, total, { duration: reduce ? 0 : 0.4, ease: [0.22, 1, 0.36, 1] });\n    return () => c.stop();\n  }, [total, mv, reduce]);\n  React.useEffect(() => {\n    if (!limitHit) return;\n    const t = setTimeout(() => setLimitHit(null), 2400);\n    return () => clearTimeout(t);\n  }, [limitHit]);\n  React.useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  const toggle = (g: SelectionGroup, id: string) => {\n    const on = selected.includes(id);\n    const count = g.options.filter((o) => selected.includes(o.id)).length;\n    if (!on && g.max && count >= g.max) {\n      setLimitHit(g.id);\n      return;\n    }\n    setSelected((s) => (on ? s.filter((x) => x !== id) : [...s, id]));\n  };\n  const setGroup = (g: SelectionGroup, on: boolean) => {\n    const ids = g.options.map((o) => o.id);\n    setSelected((s) => (on ? [...s.filter((x) => !ids.includes(x)), ...ids] : s.filter((x) => !ids.includes(x))));\n  };\n  const submit = () => {\n    if (!selected.length || status !== \"idle\") return;\n    setStatus(\"busy\");\n    const done = () => setStatus(\"done\");\n    const r = onContinue?.(selected, total);\n    if (r instanceof Promise) r.then(done, () => setStatus(\"idle\"));\n    else timer.current = setTimeout(done, reduce ? 0 : 900);\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.bg } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const check = (on: boolean, mixed = false) => (\n    <span className=\"relative grid h-[18px] w-[18px] shrink-0 place-items-center rounded-[5px] border transition-colors\" style={{ borderColor: on || mixed ? p.accent : p.faint, background: on || mixed ? p.accent : \"transparent\" }} aria-hidden=\"true\">\n      <AnimatePresence initial={false}>\n        {(on || mixed) && (\n          <motion.svg key={mixed ? \"m\" : \"c\"} width=\"11\" height=\"11\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"3.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={reduce ? false : { scale: 0.4, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={reduce ? undefined : { scale: 0.4, opacity: 0 }} transition={{ duration: 0.14 }}>\n            {mixed ? <path d=\"M6 12h12\" /> : <motion.path d=\"m5 12.5 4.5 4.5L19 7.5\" initial={reduce ? false : { pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ duration: 0.2 }} />}\n          </motion.svg>\n        )}\n      </AnimatePresence>\n    </span>\n  );\n\n  if (status === \"done\")\n    return (\n      <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n        <motion.div initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} className=\"mx-auto max-w-md px-4 py-20 text-center\" role=\"status\">\n          <span className=\"mx-auto grid h-12 w-12 place-items-center rounded-full\" style={{ background: `${p.green}22`, color: p.green }}>\n            <svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"m5 12.5 4.5 4.5L19 7.5\" />\n            </svg>\n          </span>\n          <h2 className=\"m-0 mt-5 text-[20px] font-semibold\">Workspace ready</h2>\n          <p className=\"m-0 mt-2 text-[14px] leading-[1.55]\" style={{ color: p.muted }}>\n            {selected.length} choices saved{total ? `, $${total}/mo in add-ons` : \"\"}. Your dashboards for {all.filter((o) => o.group.max && selected.includes(o.id)).map((o) => o.title.toLowerCase()).join(\", \") || \"your data\"} are being built.\n          </p>\n          <button type=\"button\" onClick={() => setStatus(\"idle\")} className={cn(\"mt-6 h-9 cursor-pointer rounded-lg border bg-transparent px-4 text-[13px] font-medium\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n            Change choices\n          </button>\n        </motion.div>\n      </section>\n    );\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-5xl px-4 py-10 @[640px]:px-6 @[640px]:py-12\">\n        <header className=\"mb-8\">\n          <p className=\"m-0 text-[12.5px] font-medium\" style={{ color: p.accent }}>\n            Step 2 of 3\n          </p>\n          <h2 className=\"m-0 mt-1.5 text-[22px] font-semibold tracking-[-0.01em] @[640px]:text-[26px]\">Customize your workspace</h2>\n          <p className=\"m-0 mt-1.5 text-[14px]\" style={{ color: p.muted }}>\n            Choose what you need now. Everything can be changed later in settings.\n          </p>\n        </header>\n\n        <div className=\"flex flex-col gap-9\">\n          {groups.map((g) => {\n            const count = g.options.filter((o) => selected.includes(o.id)).length;\n            const full = !!g.max && count >= g.max;\n            return (\n              <fieldset key={g.id} className=\"m-0 min-w-0 border-0 p-0\" aria-describedby={`${uid}-${g.id}-h`}>\n                <div className=\"mb-3 flex flex-wrap items-end justify-between gap-x-4 gap-y-2\">\n                  <div>\n                    <legend className=\"p-0 text-[15px] font-semibold\">{g.title}</legend>\n                    <p id={`${uid}-${g.id}-h`} className=\"m-0 mt-0.5 text-[12.5px]\" style={{ color: limitHit === g.id ? p.amber : p.faint }}>\n                      {limitHit === g.id ? `You can pick up to ${g.max}. Unselect one to choose another.` : g.hint}\n                    </p>\n                  </div>\n                  {g.max ? (\n                    <span className=\"text-[12.5px] tabular-nums\" style={{ color: full ? p.amber : p.muted }} aria-live=\"polite\">\n                      {count} / {g.max} selected\n                    </span>\n                  ) : (\n                    <label className=\"flex cursor-pointer items-center gap-2 text-[12.5px] has-[:focus-visible]:underline\" style={{ color: p.muted }}>\n                      <input\n                        type=\"checkbox\"\n                        className=\"sr-only\"\n                        checked={count === g.options.length}\n                        ref={(el) => {\n                          if (el) el.indeterminate = count > 0 && count < g.options.length;\n                        }}\n                        onChange={() => setGroup(g, count !== g.options.length)}\n                      />\n                      {check(count === g.options.length, count > 0 && count < g.options.length)}\n                      Select all\n                    </label>\n                  )}\n                </div>\n                <motion.div className=\"grid grid-cols-1 gap-3 @[560px]:grid-cols-2 @[860px]:grid-cols-3\" animate={limitHit === g.id && !reduce ? { x: [0, -6, 6, -4, 4, 0] } : { x: 0 }} transition={{ duration: 0.35 }}>\n                  {g.options.map((o) => {\n                    const on = selected.includes(o.id);\n                    const locked = full && !on;\n                    return (\n                      <label key={o.id} className={cn(\"relative flex cursor-pointer gap-3 rounded-xl border p-4 transition-[background-color,border-color,opacity] has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-offset-2\")} style={{ borderColor: on ? p.accent : p.border, background: on ? p.sel : p.card, opacity: locked ? 0.5 : 1, ...ring }}>\n                        <input type=\"checkbox\" className=\"sr-only\" checked={on} onChange={() => toggle(g, o.id)} aria-describedby={`${uid}-${o.id}-d`} aria-disabled={locked || undefined} />\n                        <span className=\"grid h-9 w-9 shrink-0 place-items-center rounded-lg\" style={{ background: on ? `${p.accent}22` : p.chip, color: on ? p.accent : p.muted }}>\n                          <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                            <path d={o.icon} />\n                          </svg>\n                        </span>\n                        <span className=\"min-w-0 flex-1\">\n                          <span className=\"flex items-center gap-2 text-[13.5px] font-medium\">\n                            {o.title}\n                            {o.badge && (\n                              <span className=\"rounded-full px-1.5 py-px text-[10.5px]\" style={{ background: `${p.accent}22`, color: p.accent }}>\n                                {o.badge}\n                              </span>\n                            )}\n                          </span>\n                          <span id={`${uid}-${o.id}-d`} className=\"mt-0.5 block text-[12.5px] leading-[1.45]\" style={{ color: p.muted }}>\n                            {o.description}\n                          </span>\n                          {o.price !== undefined && (\n                            <span className=\"mt-2 block text-[12.5px] font-medium tabular-nums\" style={{ color: on ? p.text : p.faint }}>\n                              +${o.price}/mo\n                            </span>\n                          )}\n                        </span>\n                        {check(on)}\n                      </label>\n                    );\n                  })}\n                </motion.div>\n              </fieldset>\n            );\n          })}\n        </div>\n\n        {/* Summary */}\n        <div className=\"sticky bottom-4 z-10 mt-9 rounded-2xl border p-4 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.5)] @[640px]:px-5\" style={{ background: p.card, borderColor: p.border }}>\n          <div className=\"flex flex-col gap-3 @[640px]:flex-row @[640px]:items-center\">\n            <ul className=\"m-0 flex min-w-0 flex-1 list-none flex-wrap gap-1.5 p-0\" aria-label=\"Selected\">\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                {all\n                  .filter((o) => selected.includes(o.id))\n                  .map((o) => (\n                    <motion.li key={o.id} layout={!reduce} initial={reduce ? false : { opacity: 0, scale: 0.85 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0, scale: 0.85 }} className=\"flex items-center gap-1 rounded-full py-0.5 pr-0.5 pl-2.5 text-[12px]\" style={{ background: p.chip }}>\n                      {o.title}\n                      <button type=\"button\" onClick={() => toggle(o.group, o.id)} aria-label={`Remove ${o.title}`} className={cn(\"grid h-5 w-5 cursor-pointer place-items-center rounded-full border-0 bg-transparent text-[13px]\", focus)} style={{ color: p.faint, ...ring }}>\n                        ×\n                      </button>\n                    </motion.li>\n                  ))}\n              </AnimatePresence>\n              {!selected.length && (\n                <li className=\"text-[12.5px]\" style={{ color: p.faint }}>\n                  Nothing selected yet\n                </li>\n              )}\n            </ul>\n            <div className=\"flex shrink-0 items-center justify-between gap-4 @[640px]:justify-end\">\n              <span className=\"text-[12.5px]\" style={{ color: p.muted }}>\n                Add-ons <motion.span className=\"text-[18px] font-semibold tabular-nums\" style={{ color: p.text }} aria-live=\"polite\">{shown}</motion.span>\n                /mo\n              </span>\n              <button type=\"button\" onClick={submit} disabled={!selected.length || status === \"busy\"} className={cn(\"flex h-10 cursor-pointer items-center gap-2 rounded-lg border-0 px-5 text-[13.5px] font-medium disabled:cursor-not-allowed disabled:opacity-50\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                {status === \"busy\" && <motion.span className=\"h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent\" animate={reduce ? undefined : { rotate: 360 }} transition={{ repeat: Infinity, duration: 0.7, ease: \"linear\" }} aria-hidden=\"true\" />}\n                {status === \"busy\" ? \"Saving…\" : \"Continue\"}\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default CheckboxSelectionCards;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}