---
title: Bento Grid for Astro
description: "A six-column Astro grid of raised cards, each with a fading visual and a soft top light."
seo:
    title: Bento Grid for Astro | Shadcn & Tailwind CSS
related:
    - /components/card
    - /components/glow-card
    - /components/masonry-grid
sidebar:
    label: "Bento Grid"
    badge: new
---

```astro
---
import { Image } from "astro:assets"
import Clock from "@lucide/astro/icons/clock"
import MapPin from "@lucide/astro/icons/map-pin"
import Sun from "@lucide/astro/icons/sun"

import {
  BentoCard,
  BentoCardContent,
  BentoCardDescription,
  BentoCardTitle,
  BentoCardVisual,
  BentoGrid,
  BentoLight,
  BentoPanel,
} from "@/components/ui/bento-grid"
import falls from "@/assets/images/babbling-brook.png"
import lake from "@/assets/images/mountain-beyond-lake-scene.png"

/** Stops on the morning walk. Times stay local to the trail. */
const stops = [
  { time: "08:10", label: "Shore path" },
  { time: "09:40", label: "Upper meadow" },
  { time: "11:15", label: "The falls" },
]

/** Day readings shown on the conditions card. */
const readings = [
  { label: "Light", value: "Clear" },
  { label: "Wind", value: "Light" },
  { label: "Trail", value: "Dry" },
]
---

<BentoGrid class="max-w-5xl mx-auto *:@md:@max-3xl:nth-[3]:odd:col-span-full">
  <BentoCard class="@3xl:col-span-3">
    <BentoLight />
    <BentoCardVisual>
      <BentoPanel class="w-full max-w-56 p-3 text-sm transition-transform duration-500 group-hover/bento-card:-translate-y-1 motion-reduce:transition-none">
        <ul class="flex flex-col gap-2">
          {stops.map((stop) => (
            <li class="flex items-center justify-between gap-3">
              <span>{stop.label}</span>
              <span class="flex items-center gap-1.5 font-mono text-xs text-muted-foreground">
                <Clock class="size-3.5" stroke-width="2" />
                {stop.time}
              </span>
            </li>
          ))}
        </ul>
      </BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Morning walk</BentoCardTitle>
      <BentoCardDescription>
        Three stops, with time to sit at the last one.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
  <BentoCard class="@3xl:col-span-3">
    <BentoLight />
    <BentoCardVisual>
      <Image
        src={lake}
        alt="A snow-capped mountain rises above a still lake, with autumn trees along the shore."
        class="absolute inset-0 size-full object-cover transition-transform duration-500 group-hover/bento-card:scale-105 motion-reduce:transition-none"
      />
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Still water</BentoCardTitle>
      <BentoCardDescription>
        The peak sits in the lake until the clouds move.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
  <BentoCard class="@3xl:col-span-2">
    <BentoLight />
    <BentoCardVisual>
      <Image
        src={falls}
        alt="A waterfall drops through a green valley, with a stream in the foreground."
        class="absolute inset-0 size-full object-cover transition-transform duration-500 group-hover/bento-card:scale-105 motion-reduce:transition-none"
      />
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>The falls</BentoCardTitle>
      <BentoCardDescription>
        Water drops through the meadow in the late light.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
  <BentoCard class="@3xl:col-span-2">
    <BentoLight />
    <BentoCardVisual>
      <BentoPanel class="w-full max-w-44 p-4 text-sm transition-transform duration-500 group-hover/bento-card:-translate-y-1 motion-reduce:transition-none">
        <p class="mb-3 flex items-center gap-2 text-xs font-medium tracking-wide text-muted-foreground uppercase">
          <Sun class="size-3.5" stroke-width="2" />
          Today
        </p>
        <dl class="flex flex-col gap-2">
          {readings.map((reading) => (
            <div class="flex items-center justify-between gap-3">
              <dt class="text-muted-foreground">{reading.label}</dt>
              <dd>{reading.value}</dd>
            </div>
          ))}
        </dl>
      </BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Conditions</BentoCardTitle>
      <BentoCardDescription>
        Clear air and a dry trail for the whole walk.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
  <BentoCard class="@3xl:col-span-2">
    <BentoLight />
    <BentoCardVisual>
      <BentoPanel class="w-full max-w-48 p-4 text-sm transition-transform duration-500 group-hover/bento-card:-translate-y-1 motion-reduce:transition-none">
        <MapPin class="mb-3 size-4 text-primary" stroke-width="2" />
        <p class="text-pretty">
          Write the light down before you leave the shore.
        </p>
      </BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Field note</BentoCardTitle>
      <BentoCardDescription>
        A short line is enough. The picture holds the rest.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
</BentoGrid>
```

## Installation

### Command

```sh
bunx --bun shadcn@latest add @gnostic/bento-grid
```

### Manual

Complete the [Installation guide](/docs/installation) first. Then copy the component files below.

No extra packages are required.

#### src/components/ui/bento-grid/bento-card-content.astro

```astro
---
/**
 * Copy under or above the visual.
 * Padding on the top is removed when a visual comes first.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="bento-card-content"
  class={cn(
    "flex flex-col gap-1.5 p-6 [[data-slot=bento-card-visual]~&]:pt-0",
    className,
  )}
  {...props}
>
  <slot />
</div>
```

#### src/components/ui/bento-grid/bento-card-description.astro

```astro
---
/**
 * Short supporting text under the title.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"p">

const { class: className, ...props } = Astro.props
---

<p
  data-slot="bento-card-description"
  class={cn("max-w-sm text-sm text-pretty text-muted-foreground", className)}
  {...props}
>
  <slot />
</p>
```

#### src/components/ui/bento-grid/bento-card-title.astro

```astro
---
/**
 * Name of the card.
 * The default tag is `h3`. Set `as` when the page needs another heading level.
 */
import type { HTMLTag, Polymorphic } from "astro/types"

import { cn } from "cn"

import type { BentoCardTitleProps } from "./types.ts"

type Props<Tag extends HTMLTag = "h3"> = Polymorphic<{ as: Tag }> &
  BentoCardTitleProps

const { as: Tag = "h3", class: className, ...props } = Astro.props
---

<Tag
  data-slot="bento-card-title"
  class={cn("font-heading text-base font-medium tracking-tight", className)}
  {...props}
>
  <slot />
</Tag>
```

#### src/components/ui/bento-grid/bento-card-visual.astro

```astro
---
/**
 * Stage for the card picture.
 * The bottom edge fades into the card surface, so a fragment can leave the stage.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="bento-card-visual"
  class={cn(
    "relative flex min-h-48 flex-1 items-center justify-center overflow-hidden mask-[linear-gradient(to_bottom,black_calc(100%-4rem),transparent)]",
    className,
  )}
  {...props}
>
  <slot />
</div>
```

#### src/components/ui/bento-grid/bento-card.astro

```astro
---
/**
 * Raised card with a lit top edge.
 * Put `BentoLight` and `BentoCardVisual` above `BentoCardContent`.
 * Hover styles on the inner parts use `group-hover/bento-card`.
 * Set `--bento-light` on this card to tint `BentoLight`.
 * The panel and light inherit the highlight and glow from this card.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="bento-card"
  class={cn(
    "[--highlight:--theme(--color-white)] dark:[--highlight:--theme(--color-white/7%)]",
    "[--glow:--theme(--color-foreground/6%)] dark:[--glow:--theme(--color-white/14%)]",

    "group/bento-card relative isolate flex min-h-80 flex-col overflow-hidden rounded-3xl bg-card text-card-foreground inset-shadow-2xs inset-shadow-(color:--highlight) ring-1 ring-foreground/8 transition-shadow duration-300 @md:col-span-2 hover:ring-foreground/12",
    className,
  )}
  {...props}
>
  <slot />
</div>
```

#### src/components/ui/bento-grid/bento-grid.astro

```astro
---
/**
 * The grid has one column below `@md`, four from `@md`, and six from `@3xl`.
 * Rows are at least `18rem` tall and grow with the content.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="bento-grid"
  class={cn(
    "grid w-full auto-rows-[minmax(18rem,auto)] grid-cols-1 @md:@max-3xl:grid-cols-[repeat(4,minmax(auto,20rem))] gap-4 @3xl:grid-cols-6",
    className,
  )}
  {...props}
>
  <slot />
</div>
```

#### src/components/ui/bento-grid/bento-light.astro

```astro
---
/**
 * Soft light from the top edge of the card.
 * It draws a haze, a faint dot field, and a lit line on the edge.
 * Tint it with `--bento-light` on the card.
 * The card supplies the neutral glow beneath the optional tint.
 * Move the light with `left-*` or `right-*` on this part.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  aria-hidden="true"
  data-slot="bento-light"
  class={cn(
    "pointer-events-none absolute inset-x-0 top-0 -z-10 h-full opacity-80 transition-opacity duration-700 group-hover/bento-card:opacity-100 motion-reduce:transition-none",
    // effect color definitions
    "[--bento-tint:--alpha(var(--bento-light,transparent)/35%)]",
    "[--bento-bright:oklch(from_var(--bento-light,var(--foreground))_max(l,0.9)_c_h)]",
    "[--bento-tint-stops:var(--bento-tint),--alpha(var(--bento-tint)/45%)_25%,--alpha(var(--bento-tint)/12%)_55%,transparent]",
    "[--bento-glow-stops:var(--glow),--alpha(var(--glow)/45%)_25%,--alpha(var(--glow)/12%)_55%,transparent]",
    // Keep the one-pixel line sharp while the haze scales.
    "after:absolute after:inset-x-1/4 after:top-0 after:h-px after:bg-linear-to-r after:from-transparent after:via-(--bento-bright)/70 after:to-transparent after:opacity-0 after:shadow-[0_0_16px_2px_var(--glow)] dark:after:opacity-100",
    className,
  )}
  {...props}
>
  <div
    data-slot="bento-light-haze"
    class:list={[
      "absolute inset-0 origin-top transition-[scale] duration-700 group-hover/bento-card:scale-110 motion-reduce:transition-none",
      "bg-[radial-gradient(50%_70%_at_50%_0%,var(--bento-tint-stops)),radial-gradient(50%_90%_at_50%_0%,var(--bento-glow-stops))]",
      "before:absolute before:inset-0 before:bg-[radial-gradient(--alpha(var(--bento-bright)/22%)_1px,transparent_1px)] before:bg-size-[12px_12px] before:mask-[radial-gradient(40%_50%_at_50%_0%,black,transparent)]",
    ]}
  >
    <slot />
  </div>
</div>
```

#### src/components/ui/bento-grid/bento-panel.astro

```astro
---
/**
 * Raised fragment on the visual stage.
 * Use it for a window, a toast, or a palette.
 * It shares the lit top edge of the card.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="bento-panel"
  class={cn(
    "relative rounded-2xl bg-popover/80 shadow-lg ring-1 ring-foreground/10 inset-shadow-2xs inset-shadow-(color:--highlight) backdrop-blur-md dark:shadow-2xl",
    className,
  )}
  {...props}
>
  <slot />
</div>
```

#### src/components/ui/bento-grid/index.ts

```ts
export { default as BentoGrid } from './bento-grid.astro'
export { default as BentoCard } from './bento-card.astro'
export { default as BentoCardContent } from './bento-card-content.astro'
export { default as BentoCardDescription } from './bento-card-description.astro'
export { default as BentoCardTitle } from './bento-card-title.astro'
export { default as BentoCardVisual } from './bento-card-visual.astro'
export { default as BentoLight } from './bento-light.astro'
export { default as BentoPanel } from './bento-panel.astro'

export type { BentoCardTitleProps } from './types.ts'
```

#### src/components/ui/bento-grid/types.ts

```ts
import type { HTMLTag } from 'astro/types'

/**
 * Props for the bento card title.
 * Element attributes such as `id` and `class` pass through.
 */
export interface BentoCardTitleProps {
    /**
     * The HTML tag for the title.
     *
     * @default "h3"
     */
    as?: HTMLTag
}
```

Component classes use the preset configured during project setup. Select the same preset in the docs before copying Manual source. To change installed component classes, edit or reinstall their source. See [Theming](/docs/theming) for details.


## Usage

```astro
---
import {
  BentoCard,
  BentoCardContent,
  BentoCardDescription,
  BentoCardTitle,
  BentoCardVisual,
  BentoGrid,
  BentoLight,
  BentoPanel,
} from "@/components/ui/bento-grid"
---

<BentoGrid class="max-w-3xl">
  <BentoCard class="[--bento-light:--theme(--color-primary)] md:col-span-3">
    <BentoLight />
    <BentoCardVisual>
      <BentoPanel class="w-full max-w-72 p-4">Your visual</BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Deploy with confidence</BentoCardTitle>
      <BentoCardDescription>
        Every pull request runs the same checks before it merges.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
</BentoGrid>
```

`BentoGrid` uses container queries to set the number of columns.

| Container width | Columns |
| --------------- | ------- |
| 0 - 448px       | 1       |
| 448px - 768px   | 4       |
| > 768px         | 6       |

Rows are at least `18rem` tall and grow with the content.

A `BentoCard` spans 2 columns for container widths above `448px` by default.

Put `BentoLight` and `BentoCardVisual` first. Put the title and the description
in `BentoCardContent`. The visual fades into the card, so a fragment can leave
the stage. `BentoPanel` is a raised window, toast, or palette on that stage.

## Light Effect

`BentoLight` is decorative. It sits behind the card content. Hover makes it
slightly larger. `prefers-reduced-motion: reduce` keeps it still.

The card sets `--highlight` for the one-pixel top edge and `--glow` for the
neutral haze. The panel inherits the same edge color.

Set `--bento-light` on the card to add a tinted haze and color the dots and
the centered line. The accent defaults to the foreground color.

```astro
<BentoCard class="[--bento-light:var(--color-primary)]">
  <BentoLight />
</BentoCard>
```

## Wide row

Set `--bento-light` to `var(--primary)` to tint each card. Two cards share the
top row. The third card fills the row under them.

```astro
---
import Headphones from "@lucide/astro/icons/headphones"
import ListMusic from "@lucide/astro/icons/list-music"
import Radio from "@lucide/astro/icons/radio"

import {
  BentoCard,
  BentoCardContent,
  BentoCardDescription,
  BentoCardTitle,
  BentoCardVisual,
  BentoGrid,
  BentoLight,
  BentoPanel,
} from "@/components/ui/bento-grid"

/** Pieces that follow the current show. */
const queue = [
  { title: "North window", length: "3:12" },
  { title: "Late lamp", length: "4:05" },
  { title: "Side A", length: "2:48" },
]

/** Readings for the full-width card. */
const levels = [
  { label: "Room", value: "Warm" },
  { label: "Mic", value: "Quiet" },
  { label: "Set", value: "18 min" },
]

/** Primary tint on every card. Two cards on top, one full row below. */
const light = "[--bento-light:var(--primary)]"
---

<BentoGrid class="mx-auto max-w-5xl *:@md:@max-3xl:last:col-span-full">
  <BentoCard class:list={["@3xl:col-span-3", light]}>
    <BentoLight class="right-12" />
    <BentoCardVisual>
      <BentoPanel class="w-full max-w-56 p-4 text-sm">
        <p class="flex items-center gap-2 text-xs font-medium tracking-wide text-muted-foreground uppercase">
          <Radio class="size-3.5 text-primary" stroke-width="2" />
          On air
        </p>
        <p class="mt-3 font-medium">Night window</p>
        <p class="mt-1 text-muted-foreground">Side A, one take</p>
      </BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Evening hour</BentoCardTitle>
      <BentoCardDescription>
        One host, one room, and a short set.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
  <BentoCard class:list={["@3xl:col-span-3", light]}>
    <BentoLight />
    <BentoCardVisual>
      <BentoPanel class="w-full max-w-64 p-4 text-sm">
        <p class="mb-3 flex items-center gap-2 text-xs font-medium tracking-wide text-muted-foreground uppercase">
          <ListMusic class="size-3.5" stroke-width="2" />
          Queue
        </p>
        <ol class="flex flex-col gap-2">
          {queue.map((piece, index) => (
            <li class="flex items-center justify-between gap-3">
              <span>
                <span class="mr-2 font-mono text-xs text-muted-foreground">
                  {index + 1}
                </span>
                {piece.title}
              </span>
              <span class="font-mono text-xs text-muted-foreground">
                {piece.length}
              </span>
            </li>
          ))}
        </ol>
      </BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>Next up</BentoCardTitle>
      <BentoCardDescription>
        The next three pieces stay in this order.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
  <BentoCard class:list={["@3xl:col-span-6", light]}>
    <BentoLight />
    <BentoCardVisual>
      <BentoPanel class="flex w-full max-w-xl items-center gap-6 p-4">
        <Headphones class="size-4 shrink-0 text-primary" stroke-width="2" />
        <dl class="grid flex-1 grid-cols-3 gap-4">
          {levels.map((level) => (
            <div>
              <dt class="text-xs text-muted-foreground">{level.label}</dt>
              <dd class="mt-1 font-medium">{level.value}</dd>
            </div>
          ))}
        </dl>
      </BentoPanel>
    </BentoCardVisual>
    <BentoCardContent>
      <BentoCardTitle>The room</BentoCardTitle>
      <BentoCardDescription>
        Warm light, a quiet mic, and time for one more piece.
      </BentoCardDescription>
    </BentoCardContent>
  </BentoCard>
</BentoGrid>
```

## Composition

```text
BentoGrid
└── BentoCard
    ├── BentoLight
    ├── BentoCardVisual
    │   └── BentoPanel
    └── BentoCardContent
        ├── BentoCardTitle
        └── BentoCardDescription
```

## Props

### BentoCardTitleProps

<AutoTypeTable
    path="../../packages/ui/src/components/ui/bento-grid/types.ts"
    name="BentoCardTitleProps"
/>

The title renders an `h3` by default. Set `as` when the page outline needs
another level. The other parts have no props of their own. Their element
attributes pass through.

Read the [installed source](/ui/r/bento-grid.json) for the complete markup.

## Slots

| Part                   | Slot    | Content                                      |
| ---------------------- | ------- | -------------------------------------------- |
| `BentoGrid`            | Default | `BentoCard` tiles.                           |
| `BentoCard`            | Default | Light, visual, and copy.                     |
| `BentoLight`           | Default | Optional extra light content. Usually empty. |
| `BentoCardVisual`      | Default | The picture or interface fragment.           |
| `BentoPanel`           | Default | A raised fragment on the stage.              |
| `BentoCardContent`     | Default | Title, description, and extra copy.          |
| `BentoCardTitle`       | Default | The card name.                               |
| `BentoCardDescription` | Default | Supporting text.                             |

## Keyboard and behavior

The light is hidden from assistive technology. The card does not add a control.
Put a link or a button in the visual or the copy when the card needs an action.
