{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bento-grid",
  "title": "Bento Grid",
  "description": "A bento layout of feature cells that span columns and rows, fall back to two and then one column as the container narrows, fade in one after another, and light up under the pointer, with a demo set of small live visuals.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/bento-grid/bento-grid.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useInView, 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\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", faint: \"rgba(245,244,241,0.2)\", cell: \"#0E0E0E\", border: \"rgba(255,255,255,0.09)\", light: \"rgba(255,255,255,0.35)\", glow: \"rgba(255,255,255,0.05)\", chip: \"rgba(255,255,255,0.06)\", strong: \"#F5F4F1\", onStrong: \"#0A0A0A\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", faint: \"rgba(10,10,10,0.18)\", cell: \"#FFFFFF\", border: \"rgba(10,10,10,0.1)\", light: \"rgba(10,10,10,0.28)\", glow: \"rgba(10,10,10,0.035)\", chip: \"rgba(10,10,10,0.05)\", strong: \"#0A0A0A\", onStrong: \"#FFFFFF\" },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\nconst GridCtx = React.createContext<{ p: Palette; cols: number; inView: boolean; reduce: boolean }>({ p: PALETTES.dark, cols: 4, inView: true, reduce: false });\n\nexport interface BentoCellProps {\n  colSpan?: number;\n  rowSpan?: number;\n  title?: string;\n  description?: string;\n  /** Artwork shown above (or behind) the text. */\n  visual?: React.ReactNode;\n  href?: string;\n  className?: string;\n  children?: React.ReactNode;\n  /** Position in the grid, for the staggered entrance. Set automatically by BentoGrid. */\n  index?: number;\n}\n\nexport function BentoCell({ colSpan = 1, rowSpan = 1, title, description, visual, href, className, children, index = 0 }: BentoCellProps) {\n  const { p, cols, inView, reduce } = React.useContext(GridCtx);\n  const ref = React.useRef<HTMLElement>(null);\n  const span = Math.min(colSpan, cols);\n  const onMove = (e: React.PointerEvent) => {\n    const el = ref.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    el.style.setProperty(\"--bx\", `${e.clientX - r.left}px`);\n    el.style.setProperty(\"--by\", `${e.clientY - r.top}px`);\n  };\n  const Tag = href ? motion.a : motion.div;\n  return (\n    <Tag\n      ref={ref as never}\n      href={href}\n      onPointerMove={onMove}\n      className={cn(\"group relative flex flex-col overflow-hidden no-underline outline-none focus-visible:ring-2\", className)}\n      style={{ gridColumn: `span ${span}`, gridRow: `span ${cols === 1 ? 1 : rowSpan}`, minHeight: cols === 1 ? 200 : undefined, borderRadius: 20, background: p.cell, border: `1px solid ${p.border}`, color: p.text }}\n      initial={reduce ? false : { opacity: 0, y: 14 }}\n      animate={inView || reduce ? { opacity: 1, y: 0 } : undefined}\n      transition={{ duration: 0.5, delay: reduce ? 0 : index * 0.07, ease: [0.22, 1, 0.36, 1] }}\n    >\n      <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 rounded-[inherit] opacity-0 transition-opacity duration-300 group-hover:opacity-100\" style={{ padding: 1, background: `radial-gradient(260px circle at var(--bx, 50%) var(--by, 0%), ${p.light}, transparent 70%)`, WebkitMask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\", WebkitMaskComposite: \"xor\", maskComposite: \"exclude\" }} />\n      <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100\" style={{ background: `radial-gradient(380px circle at var(--bx, 50%) var(--by, 0%), ${p.glow}, transparent 70%)` }} />\n      {visual && <div className=\"relative min-h-0 flex-1 transition-transform duration-500 ease-out group-hover:scale-[1.03]\">{visual}</div>}\n      {(title || description) && (\n        <div className=\"relative flex flex-col\" style={{ gap: 4, padding: \"0 20px 18px\", marginTop: visual ? 0 : \"auto\" }}>\n          {title && <span className=\"text-[15px] font-semibold tracking-[-0.01em]\">{title}</span>}\n          {description && <span className=\"text-[13px] leading-relaxed\" style={{ color: p.muted }}>{description}</span>}\n        </div>\n      )}\n      {children}\n    </Tag>\n  );\n}\n\n/* ---------------------------------------------------------------- demo visuals */\n\nfunction Bars() {\n  const { p, inView, reduce } = React.useContext(GridCtx);\n  const h = [38, 52, 44, 66, 58, 74, 69, 88, 80, 96];\n  return (\n    <div className=\"flex h-full flex-col\" style={{ padding: 20, gap: 14 }}>\n      <div className=\"flex items-baseline\" style={{ gap: 10 }}>\n        <span className=\"text-[34px] font-semibold tracking-[-0.03em] tabular-nums\">$84.2k</span>\n        <span className=\"rounded-full text-[12px] font-semibold\" style={{ padding: \"2px 8px\", background: p.chip }}>\n          ▲ 18%\n        </span>\n      </div>\n      <div className=\"flex flex-1 items-end\" style={{ gap: 8, minHeight: 120 }}>\n        {h.map((v, i) => (\n          <motion.span key={i} className=\"block flex-1 origin-bottom rounded-md\" style={{ height: `${v}%`, background: i === h.length - 1 ? p.strong : p.faint }} initial={reduce ? false : { scaleY: 0 }} animate={inView || reduce ? { scaleY: 1 } : undefined} transition={{ duration: 0.7, delay: reduce ? 0 : 0.3 + i * 0.05, ease: [0.22, 1, 0.36, 1] }} />\n        ))}\n      </div>\n    </div>\n  );\n}\n\nfunction Avatars() {\n  const { p } = React.useContext(GridCtx);\n  return (\n    <div className=\"flex h-full items-center justify-center\">\n      <div className=\"flex\">\n        {[\"MC\", \"LF\", \"AO\", \"IN\", \"+8\"].map((n, i) => (\n          <span key={n} className=\"flex items-center justify-center rounded-full text-[12px] font-semibold transition-transform duration-300 group-hover:-translate-y-1\" style={{ width: 40, height: 40, marginLeft: i ? -10 : 0, background: i === 4 ? p.strong : \"#1E1E1E\", color: i === 4 ? p.onStrong : p.text, border: `2px solid ${p.cell}`, transitionDelay: `${i * 40}ms` }}>\n            {n}\n          </span>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nfunction Uptime() {\n  const { p, reduce } = React.useContext(GridCtx);\n  return (\n    <div className=\"flex h-full flex-col justify-center\" style={{ padding: \"0 20px\", gap: 6 }}>\n      <span className=\"flex items-center text-[12px] font-medium\" style={{ gap: 8, color: p.muted }}>\n        <span className=\"relative flex\" style={{ width: 8, height: 8 }}>\n          {!reduce && <motion.span className=\"absolute inset-0 rounded-full\" style={{ background: \"#3FBF7F\" }} animate={{ scale: [1, 2.4], opacity: [0.6, 0] }} transition={{ duration: 1.6, repeat: Infinity, ease: \"easeOut\" }} />}\n          <span className=\"relative block rounded-full\" style={{ width: 8, height: 8, background: \"#3FBF7F\" }} />\n        </span>\n        All systems normal\n      </span>\n      <span className=\"text-[34px] font-semibold tracking-[-0.03em] tabular-nums\">99.99%</span>\n    </div>\n  );\n}\n\nfunction Globe() {\n  const { p } = React.useContext(GridCtx);\n  // A dotted band with a few \"regions\" lit, deterministic.\n  const dots = [];\n  for (let y = 0; y < 7; y++)\n    for (let x = 0; x < 26; x++) {\n      const lit = (x * 7 + y * 13) % 17 === 0 || (x > 4 && x < 8 && y > 1 && y < 5) || (x > 15 && x < 19 && y > 2);\n      dots.push(<circle key={`${x}-${y}`} cx={10 + x * 16} cy={12 + y * 16} r={lit ? 2.6 : 1.6} fill={lit ? p.strong : p.faint} />);\n    }\n  return (\n    <div className=\"flex h-full items-center justify-center overflow-hidden\" style={{ padding: \"10px 0\" }}>\n      <svg width=\"100%\" height=\"100%\" viewBox=\"0 0 420 120\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\" className=\"transition-transform duration-700 group-hover:translate-x-2\">\n        {dots}\n      </svg>\n    </div>\n  );\n}\n\nfunction Keys() {\n  const { p } = React.useContext(GridCtx);\n  return (\n    <div className=\"flex h-full items-center justify-center\" style={{ gap: 8 }}>\n      {[\"⌘\", \"K\"].map((k, i) => (\n        <span key={k} className=\"flex items-center justify-center rounded-xl text-[20px] font-semibold transition-transform duration-150 group-hover:translate-y-[2px]\" style={{ width: 52, height: 52, background: \"#161616\", border: `1px solid ${p.border}`, boxShadow: `0 4px 0 ${p.border}`, color: p.text, transitionDelay: `${i * 60}ms` }}>\n          {k}\n        </span>\n      ))}\n    </div>\n  );\n}\n\nfunction Integrations() {\n  const { p } = React.useContext(GridCtx);\n  const paths = [\"M4 12h16M12 4v16\", \"M5 5h14v14H5Z\", \"M12 3l9 9-9 9-9-9Z\", \"M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z\"];\n  return (\n    <div className=\"grid h-full grid-cols-2 place-content-center gap-2\" style={{ padding: 20 }}>\n      {paths.map((d, i) => (\n        <span key={d} className=\"flex items-center justify-center rounded-xl transition-transform duration-300 group-hover:rotate-6\" style={{ height: 40, background: p.chip, border: `1px solid ${p.border}`, transitionDelay: `${i * 50}ms` }}>\n          <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.text} strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d={d} />\n          </svg>\n        </span>\n      ))}\n    </div>\n  );\n}\n\nfunction Automations() {\n  const { p } = React.useContext(GridCtx);\n  const rows = [\n    [\"New order → Slack\", true],\n    [\"Refund → Email team\", false],\n  ] as const;\n  return (\n    <div className=\"flex h-full flex-col justify-center\" style={{ padding: \"16px 20px\", gap: 8 }}>\n      {rows.map(([label, on], i) => (\n        <div key={label} className=\"flex items-center justify-between rounded-xl text-[13px]\" style={{ padding: \"9px 12px\", background: p.chip, border: `1px solid ${p.border}` }}>\n          <span>{label}</span>\n          <span className={cn(\"relative block rounded-full transition-colors duration-300\", i === 1 && \"group-hover:!bg-[var(--bg-on)]\")} style={{ width: 32, height: 19, background: on ? p.strong : p.faint, [\"--bg-on\" as string]: p.strong }}>\n            <span className={cn(\"absolute top-[2.5px] block rounded-full transition-transform duration-300\", i === 1 && \"group-hover:translate-x-[13px]\")} style={{ left: 2.5, width: 14, height: 14, background: on ? p.onStrong : p.cell, transform: on ? \"translateX(13px)\" : undefined }} />\n          </span>\n        </div>\n      ))}\n    </div>\n  );\n}\n\nexport interface BentoGridProps {\n  /** BentoCell children. Leave out for the demo layout. */\n  children?: React.ReactNode;\n  /** Columns on wide containers; drops to 2, then 1, as the container narrows. */\n  columns?: number;\n  rowHeight?: number;\n  gap?: number;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nexport function BentoGrid({ children, columns = 4, rowHeight = 170, gap = 12, theme = \"dark\", className }: BentoGridProps) {\n  const p = PALETTES[theme];\n  const reduce = Boolean(useReducedMotion());\n  const ref = React.useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { once: true, amount: 0.2 });\n  const [w, setW] = React.useState(1000);\n\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(() => setW(el.clientWidth));\n    ro.observe(el);\n    setW(el.clientWidth);\n    return () => ro.disconnect();\n  }, []);\n\n  const cols = w < 520 ? 1 : w < 820 ? Math.min(2, columns) : columns;\n  const cells = children\n    ? React.Children.toArray(children).map((c, i) => (React.isValidElement<BentoCellProps>(c) ? React.cloneElement(c, { index: i }) : c))\n    : [\n        <BentoCell key=\"rev\" index={0} colSpan={2} rowSpan={2} visual={<Bars />} title=\"Revenue at a glance\" description=\"Daily numbers without opening a dashboard.\" />,\n        <BentoCell key=\"team\" index={1} visual={<Avatars />} title=\"Built for teams\" />,\n        <BentoCell key=\"up\" index={2} visual={<Uptime />} title=\"Always on\" />,\n        <BentoCell key=\"keys\" index={3} visual={<Keys />} title=\"Keyboard first\" />,\n        <BentoCell key=\"int\" index={4} visual={<Integrations />} title=\"40+ integrations\" />,\n        <BentoCell key=\"globe\" index={5} colSpan={2} visual={<Globe />} title=\"Served from the edge\" description=\"300 locations, milliseconds from every visitor.\" />,\n        <BentoCell key=\"auto\" index={6} colSpan={2} visual={<Automations />} title=\"Automations\" description=\"Wire events to the tools you already use.\" />,\n      ];\n\n  return (\n    <GridCtx.Provider value={{ p, cols, inView, reduce }}>\n      <div ref={ref} className={cn(\"grid w-full\", className)} style={{ gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`, gridAutoRows: cols === 1 ? \"auto\" : rowHeight, gap, fontFamily: \"Inter, sans-serif\" }}>\n        {cells}\n      </div>\n    </GridCtx.Provider>\n  );\n}\n\nexport default BentoGrid;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}