{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bento-grid",
  "type": "registry:component",
  "title": "Bento Grid",
  "description": "A grid of flat cards of unequal sizes. One column on a phone, two on a tablet, then 2, 3, 4 or 6: decided by the grid's own width, so it works inside any container.",
  "categories": [
    "layout"
  ],
  "dependencies": [
    "radix-ui"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn"
  ],
  "files": [
    {
      "path": "registry/layout/bento-grid.tsx",
      "type": "registry:component",
      "target": "components/layout/bento-grid.tsx",
      "content": "/**\n * @name bento-grid\n * @category layout\n * @description A grid of flat cards of unequal sizes. One column on a phone, two on a tablet, then 2, 3, 4 or 6: decided by the grid's own width, so it works inside any container.\n * @when Showing several features, figures or pieces of media as one composed block. Cells take `span` and `rowSpan`; spans are clamped to the columns there are. For equal cards use grid; for a single surface use card.\n * @example\n * // Feature block: one wide lead cell, two small ones, a full-width strip.\n * <BentoGrid columns={3}>\n *   <BentoCell span={2} rowSpan={2}>\n *     <BentoCellHeader>\n *       <BentoCellTitle>Themable from one place</BentoCellTitle>\n *       <BentoCellDescription>Light or dark, square to round, any highlight colour.</BentoCellDescription>\n *     </BentoCellHeader>\n *     <BentoCellMedia><img src=\"/shots/theme.png\" alt=\"\" /></BentoCellMedia>\n *   </BentoCell>\n *   <BentoCell><BentoCellHeader><BentoCellTitle>Accessible</BentoCellTitle></BentoCellHeader></BentoCell>\n *   <BentoCell><BentoCellHeader><BentoCellTitle>Fast</BentoCellTitle></BentoCellHeader></BentoCell>\n *   <BentoCell span=\"full\"><BentoCellHeader><BentoCellTitle>Yours to edit</BentoCellTitle></BentoCellHeader></BentoCell>\n * </BentoGrid>\n *\n * // Dashboard: four figures on top, a wide chart beside a tall list.\n * <BentoGrid columns={4} rowHeight=\"8rem\">\n *   <BentoCell><Stat label=\"Revenue\" value=\"€48k\" className=\"border-0\" /></BentoCell>\n *   <BentoCell><Stat label=\"Orders\" value=\"1,204\" className=\"border-0\" /></BentoCell>\n *   <BentoCell><Stat label=\"Visitors\" value=\"18.2k\" className=\"border-0\" /></BentoCell>\n *   <BentoCell><Stat label=\"Refunds\" value=\"12\" className=\"border-0\" /></BentoCell>\n *   <BentoCell span={3} rowSpan={3}>…chart…</BentoCell>\n *   <BentoCell rowSpan={3}>…recent activity…</BentoCell>\n * </BentoGrid>\n *\n * // Link mosaic: six columns, mixed sizes, gaps back-filled, every cell a link.\n * <BentoGrid columns={6} dense>\n *   <BentoCell span={4} rowSpan={2} interactive asChild><a href=\"/work/atlas\">…</a></BentoCell>\n *   <BentoCell span={2} interactive asChild><a href=\"/work/north\">…</a></BentoCell>\n *   <BentoCell span={2} interactive asChild><a href=\"/work/field\">…</a></BentoCell>\n *   <BentoCell span={3} interactive asChild><a href=\"/work/tide\">…</a></BentoCell>\n *   <BentoCell span={3} interactive asChild><a href=\"/work/loom\">…</a></BentoCell>\n * </BentoGrid>\n */\nimport { Slot } from \"radix-ui\";\nimport type { ComponentProps, CSSProperties } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/*\n * How the widths work. The root is a size container; the track inside it is the grid. Container widths, not\n * the viewport: under 36rem one column, from 36rem two, from 56rem the `columns` asked for. Class names are\n * written out in full below so Tailwind finds them.\n */\nconst COLUMNS = {\n  2: \"\",\n  3: \"@4xl:grid-cols-3\",\n  4: \"@4xl:grid-cols-4\",\n  6: \"@4xl:grid-cols-6\",\n} as const;\n\nconst GAP = {\n  none: \"gap-0\",\n  sm: \"gap-2\",\n  md: \"gap-4\",\n  lg: \"gap-6\",\n} as const;\n\n/*\n * A span never exceeds the columns there are: one column → every cell spans 1; two columns → at most 2; at\n * full width a span larger than the grid's `columns` becomes the whole row (the track carries data-columns,\n * and the more specific group rule wins over the plain span).\n */\nconst OVER_2 = \"@4xl:group-data-[columns=2]/bento:col-span-full\";\nconst OVER_3 = \"@4xl:group-data-[columns=3]/bento:col-span-full\";\nconst OVER_4 = \"@4xl:group-data-[columns=4]/bento:col-span-full\";\n\nconst SPAN = {\n  1: \"\",\n  2: \"@xl:col-span-2\",\n  3: cn(\"@xl:col-span-2 @4xl:col-span-3\", OVER_2),\n  4: cn(\"@xl:col-span-2 @4xl:col-span-4\", OVER_2, OVER_3),\n  5: cn(\"@xl:col-span-2 @4xl:col-span-5\", OVER_2, OVER_3, OVER_4),\n  6: cn(\"@xl:col-span-2 @4xl:col-span-6\", OVER_2, OVER_3, OVER_4),\n  full: \"col-span-full\",\n} as const;\n\n/** Row spans apply from two columns up: in a single column a cell is as tall as its content. */\nconst ROW_SPAN = {\n  1: \"\",\n  2: \"@xl:row-span-2\",\n  3: \"@xl:row-span-3\",\n  4: \"@xl:row-span-4\",\n} as const;\n\nexport type BentoGridProps = ComponentProps<\"div\"> & {\n  /** Columns at full width (56rem and up). Defaults to 3. */\n  columns?: keyof typeof COLUMNS;\n  /** Space between cells. Defaults to \"md\". */\n  gap?: keyof typeof GAP;\n  /** The least height of one row, as a CSS length; rows grow with their content. Defaults to \"11rem\". */\n  rowHeight?: string;\n  /** Back-fill holes left by larger cells. The visual order can then differ from the reading order, so use it for cells whose order does not matter. */\n  dense?: boolean;\n};\n\nexport function BentoGrid({ className, columns = 3, gap = \"md\", rowHeight = \"11rem\", dense = false, style, children, ...props }: BentoGridProps) {\n  return (\n    <div data-slot=\"bento-grid\" className={cn(\"@container w-full\", className)} style={{ \"--bento-row\": rowHeight, ...style } as CSSProperties} {...props}>\n      <div\n        data-slot=\"bento-grid-track\"\n        data-columns={columns}\n        className={cn(\"group/bento grid auto-rows-[minmax(var(--bento-row),auto)] grid-cols-1 @xl:grid-cols-2\", COLUMNS[columns], GAP[gap], dense && \"grid-flow-dense\")}\n      >\n        {children}\n      </div>\n    </div>\n  );\n}\n\nexport type BentoCellProps = ComponentProps<\"div\"> & {\n  /** Columns the cell covers at full width, or \"full\" for the whole row at every width. Defaults to 1. */\n  span?: keyof typeof SPAN;\n  /** Rows the cell covers once there are two columns or more. Defaults to 1. */\n  rowSpan?: keyof typeof ROW_SPAN;\n  /** Adds a hover and focus state: a stronger edge and a 2px lift. Use it when the whole cell is a link or a button. */\n  interactive?: boolean;\n  /** Render the child element (a link, for example) as the cell. */\n  asChild?: boolean;\n};\n\nexport function BentoCell({ className, span = 1, rowSpan = 1, interactive = false, asChild = false, ...props }: BentoCellProps) {\n  const Comp = asChild ? Slot.Root : \"div\";\n  return (\n    <Comp\n      data-slot=\"bento-cell\"\n      className={cn(\n        \"relative flex min-w-0 flex-col overflow-hidden rounded-surface border bg-card text-card-foreground\",\n        SPAN[span],\n        ROW_SPAN[rowSpan],\n        interactive &&\n          \"transition-[translate,border-color] duration-base ease-out hover:-translate-y-0.5 hover:border-border-strong focus-visible:-translate-y-0.5 focus-visible:border-border-strong motion-reduce:transition-none motion-reduce:hover:translate-y-0 motion-reduce:focus-visible:translate-y-0\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport function BentoCellHeader({ className, ...props }: ComponentProps<\"div\">) {\n  return <div data-slot=\"bento-cell-header\" className={cn(\"flex flex-col gap-1 p-5\", className)} {...props} />;\n}\n\n/** Renders an h3. */\nexport function BentoCellTitle({ className, ...props }: ComponentProps<\"h3\">) {\n  return <h3 data-slot=\"bento-cell-title\" className={cn(\"text-base leading-tight font-medium\", className)} {...props} />;\n}\n\nexport function BentoCellDescription({ className, ...props }: ComponentProps<\"p\">) {\n  return <p data-slot=\"bento-cell-description\" className={cn(\"text-sm text-muted-foreground\", className)} {...props} />;\n}\n\n/** Fills the rest of the cell, edge to edge. A direct img, video, svg or canvas child covers it. Put it before or after the header. */\nexport function BentoCellMedia({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"bento-cell-media\"\n      className={cn(\n        \"relative min-h-24 flex-1 overflow-hidden [&>canvas]:absolute [&>canvas]:inset-0 [&>canvas]:size-full [&>img]:absolute [&>img]:inset-0 [&>img]:size-full [&>img]:object-cover [&>svg]:absolute [&>svg]:inset-0 [&>svg]:size-full [&>video]:absolute [&>video]:inset-0 [&>video]:size-full [&>video]:object-cover\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "layout",
    "when": "Showing several features, figures or pieces of media as one composed block. Cells take `span` and `rowSpan`; spans are clamped to the columns there are. For equal cards use grid; for a single surface use card.",
    "example": "// Feature block: one wide lead cell, two small ones, a full-width strip.\n<BentoGrid columns={3}>\n  <BentoCell span={2} rowSpan={2}>\n    <BentoCellHeader>\n      <BentoCellTitle>Themable from one place</BentoCellTitle>\n      <BentoCellDescription>Light or dark, square to round, any highlight colour.</BentoCellDescription>\n    </BentoCellHeader>\n    <BentoCellMedia><img src=\"/shots/theme.png\" alt=\"\" /></BentoCellMedia>\n  </BentoCell>\n  <BentoCell><BentoCellHeader><BentoCellTitle>Accessible</BentoCellTitle></BentoCellHeader></BentoCell>\n  <BentoCell><BentoCellHeader><BentoCellTitle>Fast</BentoCellTitle></BentoCellHeader></BentoCell>\n  <BentoCell span=\"full\"><BentoCellHeader><BentoCellTitle>Yours to edit</BentoCellTitle></BentoCellHeader></BentoCell>\n</BentoGrid>\n\n// Dashboard: four figures on top, a wide chart beside a tall list.\n<BentoGrid columns={4} rowHeight=\"8rem\">\n  <BentoCell><Stat label=\"Revenue\" value=\"€48k\" className=\"border-0\" /></BentoCell>\n  <BentoCell><Stat label=\"Orders\" value=\"1,204\" className=\"border-0\" /></BentoCell>\n  <BentoCell><Stat label=\"Visitors\" value=\"18.2k\" className=\"border-0\" /></BentoCell>\n  <BentoCell><Stat label=\"Refunds\" value=\"12\" className=\"border-0\" /></BentoCell>\n  <BentoCell span={3} rowSpan={3}>…chart…</BentoCell>\n  <BentoCell rowSpan={3}>…recent activity…</BentoCell>\n</BentoGrid>\n\n// Link mosaic: six columns, mixed sizes, gaps back-filled, every cell a link.\n<BentoGrid columns={6} dense>\n  <BentoCell span={4} rowSpan={2} interactive asChild><a href=\"/work/atlas\">…</a></BentoCell>\n  <BentoCell span={2} interactive asChild><a href=\"/work/north\">…</a></BentoCell>\n  <BentoCell span={2} interactive asChild><a href=\"/work/field\">…</a></BentoCell>\n  <BentoCell span={3} interactive asChild><a href=\"/work/tide\">…</a></BentoCell>\n  <BentoCell span={3} interactive asChild><a href=\"/work/loom\">…</a></BentoCell>\n</BentoGrid>",
    "client": false
  }
}
