{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"motion-cards","type":"registry:ui","title":"Motion Cards","description":"A card grid that springs in with a stagger and, when filtered by tag, shrinks leaving cards away while the rest glide into their new cells.","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/ui/motion-cards.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useId, useMemo, useState } from \"react\";\nimport { AnimatePresence, LayoutGroup, motion, useReducedMotion } from \"motion/react\";\n\nexport interface MotionCardItem {\n  id: string;\n  title: string;\n  description?: string;\n  image?: string;\n  /** Small line above the title, e.g. date or author. */\n  eyebrow?: string;\n  tags: string[];\n}\n\nexport interface MotionCardsProps {\n  items: MotionCardItem[];\n  /** Label of the \"show everything\" filter; empty string hides it. */\n  allLabel?: string;\n  /** Grid columns on wide screens. */\n  columns?: number;\n  /** Seconds between each card's entrance. */\n  stagger?: number;\n  /** Spring bounce for entrances and reordering, 0 to 0.5. */\n  bounce?: number;\n  /** Show the tag filter bar. */\n  showFilter?: boolean;\n  onFilterChange?: (tag: string | null) => void;\n  className?: string;\n}\n\n/**\n * A card grid that springs in with a stagger and, when filtered by tag, lets leaving cards\n * shrink away while the rest glide into their new cells.\n */\nexport function MotionCards({\n  items,\n  allLabel = \"All\",\n  columns = 4,\n  stagger = 0.06,\n  bounce = 0.25,\n  showFilter = true,\n  onFilterChange,\n  className,\n}: MotionCardsProps) {\n  const [tag, setTag] = useState<string | null>(null);\n  const reduce = useReducedMotion();\n  const uid = useId();\n  const tags = useMemo(() => [...new Set(items.flatMap((i) => i.tags))], [items]);\n  const shown = tag ? items.filter((i) => i.tags.includes(tag)) : items;\n  const spring = reduce ? { duration: 0 } : { type: \"spring\" as const, bounce, duration: 0.6 };\n\n  const pick = (t: string | null) => {\n    setTag(t);\n    onFilterChange?.(t);\n  };\n\n  const filters: [string | null, string][] = [...(allLabel ? [[null, allLabel] as [null, string]] : []), ...tags.map((t) => [t, t] as [string, string])];\n\n  return (\n    <div className={`flex w-full flex-col gap-5 ${className ?? \"\"}`}>\n      {showFilter && (\n        <div className=\"flex flex-wrap items-center justify-between gap-3\">\n          <LayoutGroup id={uid}>\n            <div role=\"group\" aria-label=\"Filter by tag\" className=\"flex flex-wrap gap-1 rounded-full border border-border bg-card/70 p-1 backdrop-blur\">\n              {filters.map(([value, label]) => {\n                const on = tag === value;\n                return (\n                  <button\n                    key={label}\n                    type=\"button\"\n                    aria-pressed={on}\n                    onClick={() => pick(value)}\n                    className={`relative rounded-full px-3.5 py-1.5 text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring ${\n                      on ? \"text-primary-foreground\" : \"text-muted-foreground hover:text-foreground\"\n                    }`}\n                  >\n                    {on && <motion.span layoutId=\"pill\" transition={spring} className=\"absolute inset-0 rounded-full bg-primary\" />}\n                    <span className=\"relative\">{label}</span>\n                  </button>\n                );\n              })}\n            </div>\n          </LayoutGroup>\n          <p aria-live=\"polite\" className=\"text-sm tabular-nums text-muted-foreground\">\n            {shown.length} {shown.length === 1 ? \"item\" : \"items\"}\n          </p>\n        </div>\n      )}\n\n      <ul className=\"grid gap-3\" style={{ gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, max(150px, calc((100% - ${(columns - 1) * 12}px) / ${columns}))), 1fr))` }}>\n        <AnimatePresence mode=\"popLayout\" initial={!reduce}>\n          {shown.map((item, i) => (\n            <motion.li\n              key={item.id}\n              layout\n              initial={{ opacity: 0, y: 24, scale: 0.92, filter: \"blur(6px)\" }}\n              animate={{ opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }}\n              exit={{ opacity: 0, scale: 0.85, filter: \"blur(6px)\", transition: { duration: reduce ? 0 : 0.25 } }}\n              transition={reduce ? { duration: 0 } : { ...spring, delay: Math.min(i, 8) * stagger, layout: spring }}\n              whileHover={reduce ? undefined : { y: -4 }}\n              className=\"group overflow-hidden rounded-2xl border border-border bg-card shadow-[0_18px_40px_-28px_rgba(0,0,0,.9)]\"\n            >\n              {item.image && (\n                <div className=\"aspect-[16/10] overflow-hidden bg-muted\">\n                  {/* eslint-disable-next-line @next/next/no-img-element */}\n                  <img src={item.image} alt=\"\" draggable={false} className=\"size-full object-cover transition-transform duration-500 group-hover:scale-105\" />\n                </div>\n              )}\n              <div className=\"p-3.5\">\n                {item.eyebrow && <p className=\"text-[11px] text-muted-foreground\">{item.eyebrow}</p>}\n                <h3 className=\"mt-0.5 text-sm font-semibold leading-snug text-foreground\">{item.title}</h3>\n                {item.description && <p className=\"mt-1 line-clamp-2 text-xs text-muted-foreground\">{item.description}</p>}\n                <div className=\"mt-2.5 flex flex-wrap gap-1\">\n                  {item.tags.map((t) => (\n                    <span key={t} className={`rounded-full px-2 py-0.5 text-[10px] ${t === tag ? \"bg-primary text-primary-foreground\" : \"bg-muted text-muted-foreground\"}`}>\n                      {t}\n                    </span>\n                  ))}\n                </div>\n              </div>\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ul>\n    </div>\n  );\n}\n"}]}