{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stack-rolodex",
  "type": "registry:ui",
  "title": "Stack Rolodex",
  "description": "A rotating vertical pill stack that cycles through a list rolodex-style, with depth scaling, edge fading, and an optional side label.",
  "author": "Aditya Ojha <https://akoder.xyz>",
  "categories": [
    "animation",
    "marquee",
    "stack",
    "interactive"
  ],
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [],
  "meta": {
    "docs": "https://akoder.xyz/components/stack-rolodex",
    "source": "https://github.com/AdityaKodez/adityaojha/blob/main/components/ui/stack-rolodex.tsx"
  },
  "files": [
    {
      "path": "components/ui/stack-rolodex.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport { useEffect, useState, type ComponentType } from \"react\";\n\n/** Pill height in pixels. The vertical step defaults to the same value. */\nconst PILL_HEIGHT = 50;\n/** Default milliseconds between rotations. */\nconst DEFAULT_INTERVAL = 2000;\n/** Default vertical distance between neighbouring pills, in pixels. */\nconst DEFAULT_STEP = 50;\n/** Number of pills visible on each side of the active one. */\nconst VISIBLE_COUNT = 3;\n/** Seconds one rotation step takes to travel. */\nconst TRAVEL_SECONDS = 0.5;\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\n/** Fades the stack out at both ends so pills dissolve instead of clipping. */\nconst EDGE_FADE =\n  \"linear-gradient(to bottom, transparent, black 30%, black 70%, transparent)\";\n\n/**\n * Pill fill. The token carries a literal fallback so a consumer project that\n * lacks this site's muted token still renders the pill.\n */\nconst PILL_BG =\n  \"color-mix(in oklab, var(--muted, oklch(0.97 0 0)) 30%, transparent)\";\n\nexport interface StackRolodexItem {\n  /** Stable key for the pill. */\n  id: string;\n  /** Text inside the pill. */\n  name: string;\n  /** Any icon component that accepts a className. */\n  icon: ComponentType<{ className?: string }>;\n  /** Brand color the icon takes while the pill is the active one. */\n  color?: string;\n}\n\nexport interface StackRolodexProps {\n  /** Pills to cycle through. Needs at least two items to rotate. */\n  items: StackRolodexItem[];\n  /** Static line rendered beside the stack. Omit to render the stack alone. */\n  label?: string;\n  /** Milliseconds between rotations. */\n  interval?: number;\n  /** Vertical distance between neighbouring pills, in pixels. */\n  step?: number;\n  className?: string;\n}\n\n/**\n * A rotating vertical pill stack, rolodex-style. The active index grows\n * forever and each pill's offset wraps into a centred window, so the rotation\n * never hits an edge or snaps back to the start. Pills that cross the wrap\n * point teleport with a zero-duration transition instead of sweeping across\n * the stack.\n */\nexport function StackRolodex({\n  items,\n  label,\n  interval = DEFAULT_INTERVAL,\n  step = DEFAULT_STEP,\n  className,\n}: StackRolodexProps) {\n  const [{ active, previous }, setActive] = useState({ active: 0, previous: 0 });\n  const reduceMotion = useReducedMotion();\n\n  const count = items.length;\n  const half = Math.floor(count / 2);\n  const stackHeight = 2 * VISIBLE_COUNT * step + PILL_HEIGHT;\n\n  useEffect(() => {\n    if (count < 2) return;\n    const id = setInterval(() => {\n      setActive((s) => ({ active: s.active + 1, previous: s.active }));\n    }, interval);\n    return () => clearInterval(id);\n  }, [count, interval]);\n\n  if (count === 0) return null;\n\n  /**\n   * Signed distance from the active pill, wrapped into a centred window.\n   * Negative means above the centre, positive means below.\n   */\n  const offsetFor = (index: number, activeStep: number) => {\n    const wrapped = (((index - activeStep) % count) + count) % count;\n    return wrapped > half ? wrapped - count : wrapped;\n  };\n\n  return (\n    <div\n      className={cn(\n        \"flex flex-wrap items-center justify-center gap-8\",\n        className,\n      )}\n    >\n      <ul\n        className=\"relative w-44 shrink-0\"\n        style={{\n          height: stackHeight,\n          maskImage: EDGE_FADE,\n          WebkitMaskImage: EDGE_FADE,\n        }}\n      >\n        {items.map((item, index) => {\n          const d = offsetFor(index, active);\n          const was = offsetFor(index, previous);\n          const crossed = Math.abs(d - was) > 1;\n          const distance = Math.abs(d);\n          const Icon = item.icon;\n          // The brand color lands on the icon only; the pill itself keeps its\n          // neutral styling in every slot.\n          const tint = d === 0 ? item.color : undefined;\n\n          return (\n            <motion.li\n              key={item.id}\n              initial={false}\n              className={cn(\n                \"absolute left-0 right-0 mx-auto flex w-40 items-center justify-center gap-3.5\",\n                \"rounded-full\",\n                d === 0 ? \"shadow-xs\" : \"shadow-none\",\n              )}\n              style={{\n                height: PILL_HEIGHT,\n                top: \"50%\",\n                marginTop: -PILL_HEIGHT / 2,\n                zIndex: count - distance,\n                background: PILL_BG,\n              }}\n              animate={{\n                y: d * step,\n                scale: 1 - distance * 0.14,\n                opacity: distance > VISIBLE_COUNT ? 0 : 1 - distance * 0.45,\n              }}\n              transition={\n                crossed || reduceMotion\n                  ? { duration: 0 }\n                  : { duration: TRAVEL_SECONDS, ease: EASE }\n              }\n            >\n              {/* The pill text names the item, so the icon is decorative. */}\n              <span\n                aria-hidden\n                className=\"flex motion-safe:transition-colors motion-safe:duration-500\"\n                style={tint ? { color: tint } : undefined}\n              >\n                <Icon className=\"size-6\" />\n              </span>\n              <span className=\"truncate text-base font-medium\">\n                {item.name}\n              </span>\n            </motion.li>\n          );\n        })}\n      </ul>\n\n      {label ? (\n        <motion.p\n          initial={{ opacity: 0, y: 8 }}\n          animate={{ opacity: 1, y: 0 }}\n          transition={\n            reduceMotion\n              ? { duration: 0 }\n              : { duration: TRAVEL_SECONDS, ease: EASE }\n          }\n          className=\"whitespace-nowrap text-2xl font-medium tracking-tight sm:text-4xl\"\n        >\n          {label}\n        </motion.p>\n      ) : null}\n    </div>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "## Installation\n\n```bash\nnpx shadcn@latest add @akoder/stack-rolodex\n```\n\n## Usage\n\n```tsx\nimport { StackRolodex } from \"@/components/ui/stack-rolodex\";\nimport { SiGithub, SiPrisma, SiSupabase, SiVercel } from \"react-icons/si\";\n\nconst STACK = [\n  { id: \"vercel\", name: \"Vercel\", icon: SiVercel },\n  { id: \"github\", name: \"GitHub\", icon: SiGithub },\n  { id: \"supabase\", name: \"Supabase\", icon: SiSupabase, color: \"#3ECF8E\" },\n  { id: \"prisma\", name: \"Prisma\", icon: SiPrisma, color: \"#16A394\" },\n];\n\nexport function StackSection() {\n  return <StackRolodex items={STACK} label=\"in my stack\" />;\n}\n```\n\n`items` takes any icon component that accepts a `className`, such as react-icons, lucide-react, or your own SVG components. `interval` is the milliseconds between rotations and `step` the pixel distance between pills, with three pills visible on each side of the active one. Omit `label` to render the stack on its own. An item can carry its brand `color`, which the icon takes while its pill is the active one; items without a color keep the neutral styling."
}