{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "grid-bento-ascii",
  "title": "Grid Bento ASCII",
  "description": "A 2x2 bento layout primitive built on its own content/seam track grid (a real vertical rule, horizontal rule and ┼ junction between the four tiles), where activating a tile re-spans it across every track, seam included, so the junction has nowhere left to be drawn.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/core/grid-bento-ascii/component.tsx",
      "content": "\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\n\n// ---------------------------------------------------------------------------\n// GridBentoAscii — a 2x2 bento layout primitive where the seams between\n// cells are real box-drawing structure, not a picture of one: the grid is\n// built on its own track grid (content / seam / content, on both axes), so\n// there is exactly one vertical rule, one horizontal rule and one ┼\n// junction glyph, all as real elements at real grid positions. Activating a\n// cell doesn't recolor anything — it re-spans that cell across every track,\n// content and seam alike, so the seam literally has nowhere left to be\n// drawn and disappears as a structural consequence, not an animation\n// playing on its own clock. Collapsing brings the topology, and the seam,\n// back. This mechanic does not exist on a single box: it needs the seam's\n// topology to have something to gain or lose.\n// ---------------------------------------------------------------------------\n\nexport interface BentoCell {\n  id: string;\n  title: string;\n  description?: string;\n  content?: ReactNode;\n}\n\nexport interface GridBentoAsciiProps {\n  /** the grid's four tiles */\n  cells: [BentoCell, BentoCell, BentoCell, BentoCell];\n  /** extra classes merged onto the rendered root element */\n  className?: string;\n}\n\nexport function GridBentoAscii({ cells, className = \"\" }: GridBentoAsciiProps) {\n  const [heroId, setHeroId] = useState<string | null>(null);\n\n  const positions: Record<number, { col: string; row: string }> = {\n    0: { col: \"1 / 2\", row: \"1 / 2\" },\n    1: { col: \"3 / 4\", row: \"1 / 2\" },\n    2: { col: \"1 / 2\", row: \"3 / 4\" },\n    3: { col: \"3 / 4\", row: \"3 / 4\" },\n  };\n\n  const heroIndex = heroId ? cells.findIndex((c) => c.id === heroId) : -1;\n  const expanded = heroIndex !== -1;\n\n  return (\n    <div\n      data-grid-bento-ascii\n      className={`relative grid aspect-square w-full max-w-md gap-0 font-mono ${className}`}\n      style={{\n        gridTemplateColumns: \"1fr 1.4em 1fr\",\n        gridTemplateRows: \"1fr 1.4em 1fr\",\n      }}\n    >\n      {/* seams: real elements at real grid tracks, only rendered while every\n          cell is at its own resting position */}\n      {!expanded && (\n        <>\n          <div\n            aria-hidden\n            className=\"pointer-events-none bg-border transition-opacity duration-150 motion-reduce:transition-none\"\n            style={{ gridColumn: \"2 / 3\", gridRow: \"1 / 4\", width: 1, justifySelf: \"center\" }}\n          />\n          <div\n            aria-hidden\n            className=\"pointer-events-none bg-border transition-opacity duration-150 motion-reduce:transition-none\"\n            style={{ gridColumn: \"1 / 4\", gridRow: \"2 / 3\", height: 1, alignSelf: \"center\" }}\n          />\n          <span\n            aria-hidden\n            className=\"pointer-events-none grid select-none place-items-center text-border transition-opacity duration-150 motion-reduce:transition-none\"\n            style={{ gridColumn: \"2 / 3\", gridRow: \"2 / 3\" }}\n          >\n            +\n          </span>\n        </>\n      )}\n\n      {cells.map((cell, i) => {\n        const isHero = heroId === cell.id;\n        const hiddenByHero = expanded && !isHero;\n        const style = isHero && expanded ? { col: \"1 / 4\", row: \"1 / 4\" } : positions[i]!;\n\n        return (\n          <button\n            key={cell.id}\n            type=\"button\"\n            data-cell={cell.id}\n            aria-pressed={isHero}\n            aria-label={isHero ? `Collapse ${cell.title}` : `Expand ${cell.title}`}\n            aria-hidden={hiddenByHero || undefined}\n            tabIndex={hiddenByHero ? -1 : 0}\n            onClick={() => setHeroId(isHero ? null : cell.id)}\n            className={`group relative flex flex-col items-start justify-end overflow-hidden rounded-sm border border-border bg-surface p-3 text-left transition-[opacity,border-color] duration-150 motion-reduce:transition-none hover:border-foreground/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ns-accent ${\n              hiddenByHero ? \"pointer-events-none opacity-0\" : \"opacity-100\"\n            }`}\n            style={{ gridColumn: style.col, gridRow: style.row }}\n          >\n            {isHero && expanded && (\n              <span\n                aria-hidden\n                data-hero-badge\n                className=\"absolute right-2 top-2 select-none rounded-sm border border-border bg-background px-2 py-1 text-[10px] uppercase tracking-wider text-ns-muted\"\n              >\n                click to collapse\n              </span>\n            )}\n            {cell.content}\n            <span className=\"text-sm font-semibold text-foreground\">{cell.title}</span>\n            {cell.description && (\n              <span className=\"mt-1 text-xs text-ns-muted group-hover:text-foreground/80\">\n                {cell.description}\n              </span>\n            )}\n          </button>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/grid-bento-ascii.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-ns-muted": "var(--ns-muted)",
      "color-ns-accent": "var(--ns-accent)",
      "color-surface": "var(--surface)"
    },
    "light": {
      "ns-muted": "#4d4d4d",
      "ns-accent": "#006bff",
      "surface": "#fafafa"
    },
    "dark": {
      "ns-muted": "#8f8f8f",
      "surface": "#171717"
    }
  },
  "meta": {
    "collection": "core",
    "tags": [
      "grid",
      "bento",
      "layout",
      "ascii",
      "mono",
      "box-drawing"
    ],
    "instruction": "Build <GridBentoAscii cells className?> where cells is exactly a 4-tuple of BentoCell ({id, title, description?, content?}). STRUCTURE: a CSS grid with an explicit 3x3 track template — gridTemplateColumns/Rows of `1fr 1.4em 1fr` — so tracks 1 and 3 hold content and track 2 on each axis is a dedicated seam track, not a gap. At rest (no tile activated) the four tiles occupy the four content x content corners (col/row `1/2` and `3/4` in every combination) and three real seam elements are rendered at the seam tracks: a 1px-wide vertical bar (bg-border) spanning the full grid height at column `2/3`, a 1px-tall horizontal bar spanning the full grid width at row `2/3`, and a `┼` box-drawing glyph (text-border) at their crossing, column `2/3` row `2/3` — three genuine elements at real grid positions, not a painted picture of a cross. THE MECHANIC — the one that needs more than one cell and a real track topology to exist: each tile is a real <button data-cell={id} aria-pressed aria-label> covering its own content; clicking a tile that isn't the current hero sets it as hero, re-spanning ONLY that button's own gridColumn/gridRow to `1/4` on both axes — across every track, seam tracks included — while the seam elements and the other three tiles unmount their visible presence (opacity-0, pointer-events-none, aria-hidden, tabIndex=-1, kept mounted rather than removed so focus/state isn't lost). Because the hero's own grid area now covers the seam tracks, the seam elements are conditionally not rendered at all while any tile is expanded — the junction doesn't fade out, it structurally has nowhere left to be drawn, which is the whole point: this could not exist on a single box, since there would be no second cell's boundary to lose. Clicking the hero tile again (aria-label flips to 'Collapse {title}', a small aria-hidden 'click to collapse' badge appears in its corner) sets hero back to null, restoring all four positions and all three seam elements in the same render. ACCESSIBILITY: every tile is a real <button> (not a div with an onClick) so Tab/Enter/Space work natively with no keydown handler required; aria-pressed tracks whether that specific tile is the current hero; aria-label always names the action ('Expand {title}' / 'Collapse {title}'), never just the state; hover (border-foreground/25) and focus-visible (outline-2 outline-offset-2 outline-ns-accent, no outline-none on the same element) are visually distinct from rest; the three hidden-while-expanded tiles are excluded from the tab order via tabIndex=-1 so Tab doesn't land on invisible controls, and aria-hidden keeps them out of the accessibility tree while a tile is expanded. Reduced motion drops the small opacity transition on tile visibility to an instant change. Colors are token-only (--border, --foreground, --ns-muted, --ns-accent, --surface), no hex."
  },
  "type": "registry:ui"
}