{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "list-group",
  "title": "List Group",
  "description": "A framed group of rows for settings menus and navigation lists: icons, descriptions, count badges, a danger row for destructive actions, and in selectable mode an active highlight that slides from row to row with arrow-key navigation.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/list-group/list-group.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { 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 type ListGroupIcon = \"user\" | \"bell\" | \"lock\" | \"card\" | \"globe\" | \"trash\" | \"settings\" | \"mail\";\n\nexport interface ListGroupItem {\n  id: string;\n  label: string;\n  description?: string;\n  icon?: ListGroupIcon | React.ReactNode;\n  /** A count or short tag on the right. */\n  badge?: string | number;\n  href?: string;\n  disabled?: boolean;\n  /** danger: for destructive actions like \"Delete account\". */\n  tone?: \"default\" | \"danger\";\n}\n\nexport interface ListGroupProps {\n  items?: ListGroupItem[];\n  /** single: one item is active and the highlight slides to it. none: plain actions or links. */\n  selectable?: \"single\" | \"none\";\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (id: string) => void;\n  /** Called for every activation (click, Enter), selectable or not. */\n  onItemClick?: (item: ListGroupItem) => void;\n  /** bordered: framed with dividers. inset: framed, rows as separate pills. flush: no frame. */\n  variant?: \"bordered\" | \"inset\" | \"flush\";\n  showChevron?: boolean;\n  label?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.52)\", faint: \"rgba(245,244,241,0.28)\", panel: \"#0E0E0E\", border: \"rgba(255,255,255,0.09)\", line: \"rgba(255,255,255,0.06)\", hover: \"rgba(255,255,255,0.04)\", active: \"rgba(255,255,255,0.08)\", bar: \"#F5F4F1\", icon: \"rgba(255,255,255,0.06)\", badge: \"rgba(255,255,255,0.1)\", danger: \"#FF7A6B\", focus: \"rgba(245,244,241,0.85)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.52)\", faint: \"rgba(10,10,10,0.28)\", panel: \"#FFFFFF\", border: \"rgba(10,10,10,0.1)\", line: \"rgba(10,10,10,0.06)\", hover: \"rgba(10,10,10,0.03)\", active: \"rgba(10,10,10,0.05)\", bar: \"#0A0A0A\", icon: \"rgba(10,10,10,0.05)\", badge: \"rgba(10,10,10,0.07)\", danger: \"#E5484D\", focus: \"rgba(10,10,10,0.85)\" },\n};\n\nconst ICONS: Record<ListGroupIcon, string[]> = {\n  user: [\"M16 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z\", \"M4.5 20.5a7.5 7.5 0 0 1 15 0\"],\n  bell: [\"M5 17h14l-1.4-2a3.2 3.2 0 0 1-.6-1.9V10a5 5 0 0 0-10 0v3.1a3.2 3.2 0 0 1-.6 1.9Z\", \"M10 20a2.2 2.2 0 0 0 4 0\"],\n  lock: [\"M6 11h12a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2Z\", \"M8 11V7.5a4 4 0 0 1 8 0V11\"],\n  card: [\"M5.5 5h13A2.5 2.5 0 0 1 21 7.5v9a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 16.5v-9A2.5 2.5 0 0 1 5.5 5Z\", \"M3 10h18\"],\n  globe: [\"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z\", \"M3 12h18\", \"M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z\"],\n  trash: [\"M4 7h16\", \"M9.5 7V5.2A1.2 1.2 0 0 1 10.7 4h2.6a1.2 1.2 0 0 1 1.2 1.2V7\", \"m6 7 .9 12.2A2 2 0 0 0 8.9 21h6.2a2 2 0 0 0 2-1.8L18 7\"],\n  settings: [\"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z\", \"M19.4 13a7.6 7.6 0 0 0 0-2l2-1.6-2-3.4-2.4 1a7.4 7.4 0 0 0-1.7-1L15 3.5h-4l-.4 2.5a7.4 7.4 0 0 0-1.7 1l-2.4-1-2 3.4L6.6 11a7.6 7.6 0 0 0 0 2l-2 1.6 2 3.4 2.4-1a7.4 7.4 0 0 0 1.7 1l.4 2.5h4l.4-2.5a7.4 7.4 0 0 0 1.7-1l2.4 1 2-3.4Z\"],\n  mail: [\"M5.5 5h13A2.5 2.5 0 0 1 21 7.5v9a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 16.5v-9A2.5 2.5 0 0 1 5.5 5Z\", \"m3.5 7.5 7.4 5.2a2 2 0 0 0 2.2 0l7.4-5.2\"],\n};\n\nconst DEFAULT_ITEMS: ListGroupItem[] = [\n  { id: \"profile\", label: \"Profile\", description: \"Name, photo and bio\", icon: \"user\" },\n  { id: \"notifications\", label: \"Notifications\", icon: \"bell\", badge: 3 },\n  { id: \"security\", label: \"Security\", description: \"Password and two-factor\", icon: \"lock\" },\n  { id: \"billing\", label: \"Billing\", description: \"Pro plan · renews Oct 12\", icon: \"card\" },\n  { id: \"language\", label: \"Language\", description: \"English (US)\", icon: \"globe\" },\n  { id: \"delete\", label: \"Delete account\", icon: \"trash\", tone: \"danger\" },\n];\n\nexport function ListGroup({ items = DEFAULT_ITEMS, selectable = \"single\", value, defaultValue = \"profile\", onValueChange, onItemClick, variant = \"bordered\", showChevron = true, label = \"Settings\", theme = \"dark\", className }: ListGroupProps) {\n  const p = PALETTES[theme];\n  const uid = React.useId();\n  const reduce = Boolean(useReducedMotion());\n  const [internal, setInternal] = React.useState(defaultValue);\n  const active = selectable === \"single\" ? (value ?? internal) : undefined;\n  const listRef = React.useRef<HTMLUListElement>(null);\n  const [focusIdx, setFocusIdx] = React.useState(() => Math.max(0, items.findIndex((i) => i.id === active)));\n\n  const activate = (item: ListGroupItem) => {\n    if (item.disabled) return;\n    if (selectable === \"single\") {\n      if (value === undefined) setInternal(item.id);\n      onValueChange?.(item.id);\n    }\n    onItemClick?.(item);\n  };\n\n  const onKey = (e: React.KeyboardEvent, i: number) => {\n    const step = e.key === \"ArrowDown\" ? 1 : e.key === \"ArrowUp\" ? -1 : 0;\n    if (step || e.key === \"Home\" || e.key === \"End\") {\n      e.preventDefault();\n      let n = e.key === \"Home\" ? 0 : e.key === \"End\" ? items.length - 1 : i;\n      // Skip disabled rows.\n      for (let k = 0; k < items.length; k++) {\n        if (step) n = (n + step + items.length) % items.length;\n        if (!items[n].disabled) break;\n        if (!step) n = (n + (e.key === \"Home\" ? 1 : -1) + items.length) % items.length;\n      }\n      setFocusIdx(n);\n      listRef.current?.querySelectorAll<HTMLElement>(\"[data-lg-row]\")[n]?.focus();\n    }\n  };\n\n  const framed = variant !== \"flush\";\n  const inset = variant === \"inset\";\n\n  return (\n    <ul\n      ref={listRef}\n      role={selectable === \"single\" ? \"listbox\" : \"list\"}\n      aria-label={label}\n      className={cn(\"m-0 flex list-none flex-col p-0\", className)}\n      style={{ gap: inset ? 4 : 0, padding: inset ? 6 : 0, borderRadius: 16, background: framed ? p.panel : \"transparent\", border: framed ? `1px solid ${p.border}` : undefined, overflow: \"hidden\", fontFamily: \"Inter, sans-serif\" }}\n    >\n      {items.map((item, i) => {\n        const on = active === item.id;\n        const danger = item.tone === \"danger\";\n        const color = danger ? p.danger : p.text;\n        const iconNode =\n          typeof item.icon === \"string\" && item.icon in ICONS ? (\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              {ICONS[item.icon as ListGroupIcon].map((d) => (\n                <path key={d} d={d} />\n              ))}\n            </svg>\n          ) : (\n            item.icon\n          );\n        const inner = (\n          <>\n            {on && (\n              <motion.span layoutId={`${uid}-active`} className=\"absolute inset-0\" style={{ background: p.active, borderRadius: inset ? 11 : 0 }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 520, damping: 40 }}>\n                {!inset && <span className=\"absolute top-2 bottom-2 left-0 rounded-r-full\" style={{ width: 3, background: p.bar }} />}\n              </motion.span>\n            )}\n            {iconNode && (\n              <span className=\"relative flex shrink-0 items-center justify-center\" style={{ width: 32, height: 32, borderRadius: 9, background: danger ? \"transparent\" : p.icon, color: danger ? p.danger : on ? p.text : p.muted, transition: \"color 0.15s ease\" }}>\n                {iconNode}\n              </span>\n            )}\n            <span className=\"relative flex min-w-0 flex-1 flex-col\" style={{ gap: 1 }}>\n              <span className={cn(\"truncate text-[14px]\", on ? \"font-semibold\" : \"font-medium\")} style={{ color }}>\n                {item.label}\n              </span>\n              {item.description && (\n                <span className=\"truncate text-[12.5px]\" style={{ color: p.muted }}>\n                  {item.description}\n                </span>\n              )}\n            </span>\n            {item.badge !== undefined && (\n              <span className=\"relative shrink-0 rounded-full text-[11.5px] font-semibold tabular-nums\" style={{ padding: \"2px 8px\", background: p.badge, color: p.text }}>\n                {item.badge}\n              </span>\n            )}\n            {showChevron && !danger && (\n              <motion.svg className=\"relative shrink-0\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.faint} strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" variants={{ rest: { x: 0 }, hover: { x: reduce ? 0 : 3 } }} transition={{ type: \"spring\", stiffness: 500, damping: 26 }}>\n                <path d=\"m9 6 6 6-6 6\" />\n              </motion.svg>\n            )}\n          </>\n        );\n        const rowClass = \"group relative flex w-full items-center text-left no-underline outline-none focus-visible:ring-2 focus-visible:ring-inset\";\n        const rowStyle: React.CSSProperties = {\n          gap: 12,\n          padding: \"11px 14px\",\n          borderRadius: inset ? 11 : 0,\n          borderTop: !inset && i > 0 && framed ? `1px solid ${p.line}` : !framed && i > 0 ? `1px solid ${p.line}` : undefined,\n          opacity: item.disabled ? 0.45 : 1,\n          cursor: item.disabled ? \"not-allowed\" : \"pointer\",\n          background: \"transparent\",\n          [\"--tw-ring-color\" as string]: p.focus,\n        };\n        const hoverable = !item.disabled && !on ? \"hover:bg-[var(--lg-hover)]\" : \"\";\n        const style = { ...rowStyle, [\"--lg-hover\" as string]: p.hover };\n        const tab = selectable === \"single\" ? (i === focusIdx ? 0 : -1) : undefined;\n        return (\n          <li key={item.id} role={selectable === \"single\" ? \"option\" : undefined} aria-selected={selectable === \"single\" ? on : undefined} aria-disabled={item.disabled || undefined} className=\"relative\">\n            {item.href && !item.disabled ? (\n              <motion.a data-lg-row=\"\" href={item.href} aria-current={on ? \"page\" : undefined} initial=\"rest\" whileHover=\"hover\" tabIndex={tab} onClick={() => activate(item)} onKeyDown={(e) => onKey(e, i)} onFocus={() => setFocusIdx(i)} className={cn(rowClass, hoverable)} style={style}>\n                {inner}\n              </motion.a>\n            ) : (\n              <motion.button data-lg-row=\"\" type=\"button\" disabled={item.disabled} initial=\"rest\" whileHover={item.disabled ? undefined : \"hover\"} tabIndex={tab} onClick={() => activate(item)} onKeyDown={(e) => onKey(e, i)} onFocus={() => setFocusIdx(i)} className={cn(rowClass, hoverable, \"border-none\")} style={style}>\n                {inner}\n              </motion.button>\n            )}\n          </li>\n        );\n      })}\n    </ul>\n  );\n}\n\nexport default ListGroup;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}