Bento Grid
A responsive bento grid for React and Tailwind CSS, made for feature sections and landing pages. Cards span columns and rows, and on hover or keyboard focus the border and background visual brighten and the content lifts to reveal a call to action. Each linked card is a single, focusable link.
- Responsive spans
- Hover reveal CTA
- Whole-card links
- Next.js Link support
- prefers-reduced-motion
Deploy in one command
Push to main and your app is live everywhere in seconds, with instant rollbacks.
Read the deploy guideGlobal edge network
Requests are served from the region closest to your users.
Learn moreBuilt-in analytics
Privacy-friendly metrics, no cookies.
Learn moreSecure by default
TLS, DDoS shielding and secrets vault.
Learn morePreviews for every pull request
Each branch gets its own URL, so reviewers can click through changes before they merge.
See preview deployments"use client";
// Client module so `linkAs={Link}` (a component) can be passed as a prop.
import Link from "next/link";
import { BarChart3, GitPullRequest, Globe, Lock, Rocket } from "lucide-react";
import { BentoCard, BentoGrid } from "@/components/dusk/bento-grid/bento-grid";
function TerminalVisual() {
const lines = ["$ dusk deploy --prod", "✓ Built in 2.1s", "✓ Uploaded 48 files", "✓ Live on 32 regions"];
return (
<div className="absolute inset-0">
<div className="absolute top-6 right-6 left-6 rounded-lg border border-white/10 bg-black/50 p-4 font-mono text-xs leading-6 text-white/60 sm:left-auto sm:w-72">
{lines.map((line, i) => (
<p key={line} className={i === 0 ? "text-white/80" : "text-white/50"}>
{line}
</p>
))}
</div>
</div>
);
}
function GlobeVisual() {
return (
<div className="absolute inset-0 flex items-start justify-center pt-10">
<div className="relative size-56 rounded-full border border-white/10">
<div className="absolute inset-6 rounded-full border border-white/10" />
<div className="absolute inset-y-0 left-1/2 w-px bg-white/10" />
<div className="absolute inset-x-0 top-1/2 h-px bg-white/10" />
<div className="absolute inset-x-6 inset-y-0 rounded-[50%] border border-white/10" />
{[
[30, 40],
[62, 28],
[48, 66],
[74, 58],
].map(([left, top]) => (
<span
key={`${left}-${top}`}
className="absolute size-1.5 rounded-full bg-white/60"
style={{ left: `${left}%`, top: `${top}%` }}
/>
))}
</div>
</div>
);
}
function ChartVisual() {
const bars = [40, 65, 45, 80, 60, 95, 70];
return (
<div className="absolute inset-x-6 top-6 flex h-28 items-end gap-2">
{bars.map((h, i) => (
<div
key={i}
className="flex-1 rounded-t bg-white/10"
style={{ height: `${h}%` }}
/>
))}
</div>
);
}
function PreviewVisual() {
const previews = [
{ branch: "fix/checkout-tax", url: "checkout-tax.preview.app" },
{ branch: "feat/saved-carts", url: "saved-carts.preview.app" },
];
return (
<div className="absolute top-6 right-6 left-6 grid gap-2 sm:left-auto sm:w-80">
{previews.map((preview) => (
<div
key={preview.branch}
className="flex items-center justify-between gap-3 rounded-md border border-white/10 bg-black/40 px-3 py-2 text-xs"
>
<span className="font-mono text-white/70">{preview.branch}</span>
<span className="truncate text-white/55">{preview.url}</span>
</div>
))}
</div>
);
}
export default function BentoGridDemo() {
return (
<BentoGrid className="max-w-4xl">
<BentoCard
colSpan={2}
href="#examples"
linkAs={Link}
icon={<Rocket />}
title="Deploy in one command"
description="Push to main and your app is live everywhere in seconds, with instant rollbacks."
cta="Read the deploy guide"
background={<TerminalVisual />}
/>
<BentoCard
rowSpan={2}
href="#examples"
linkAs={Link}
icon={<Globe />}
title="Global edge network"
description="Requests are served from the region closest to your users."
background={<GlobeVisual />}
/>
<BentoCard
href="#examples"
linkAs={Link}
icon={<BarChart3 />}
title="Built-in analytics"
description="Privacy-friendly metrics, no cookies."
background={<ChartVisual />}
/>
<BentoCard
href="#examples"
linkAs={Link}
icon={<Lock />}
title="Secure by default"
description="TLS, DDoS shielding and secrets vault."
/>
<BentoCard
colSpan={3}
href="#examples"
linkAs={Link}
icon={<GitPullRequest />}
title="Previews for every pull request"
description="Each branch gets its own URL, so reviewers can click through changes before they merge."
cta="See preview deployments"
background={<PreviewVisual />}
/>
</BentoGrid>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/bento-grid.json1. Install the dependencies.
npm install motion lucide-react2. Copy the source into
components/dusk/bento-grid/bento-grid.tsx.bento-grid.tsx "use client"; import * as React from "react"; import { ArrowRight } from "lucide-react"; import { cn } from "@/lib/utils"; type Columns = 2 | 3 | 4; const BentoContext = React.createContext<Columns>(3); const gridColumns: Record<Columns, string> = { 2: "sm:grid-cols-2", 3: "sm:grid-cols-2 lg:grid-cols-3", 4: "sm:grid-cols-2 lg:grid-cols-4", }; // Spans only kick in from `sm`, where the grid has 2+ columns. const colSpans: Record<number, string> = { 1: "", 2: "sm:col-span-2", 3: "sm:col-span-2 lg:col-span-3", 4: "sm:col-span-2 lg:col-span-4", }; const rowSpans: Record<number, string> = { 1: "", 2: "sm:row-span-2", 3: "sm:row-span-3", }; export interface BentoGridProps extends React.HTMLAttributes<HTMLDivElement> { /** Columns on large screens. Phones get one column, tablets two. */ columns?: Columns; } /** * A responsive bento layout: one column on phones, two on tablets and * `columns` from `lg`. Rows are at least 14rem tall; give a card `rowSpan` to * make it taller. Set `auto-rows-*` in `className` to change the row height. */ export function BentoGrid({ columns = 3, className, children, ...props }: BentoGridProps) { return ( <BentoContext.Provider value={columns}> <div data-slot="bento-grid" className={cn("grid w-full auto-rows-[minmax(14rem,auto)] grid-cols-1 gap-4", gridColumns[columns], className)} {...props} > {children} </div> </BentoContext.Provider> ); } type CardBaseProps = Omit< React.HTMLAttributes<HTMLElement>, "title" | "onDrag" | "onDragStart" | "onDragEnd" | "onAnimationStart" >; export interface BentoCardProps extends CardBaseProps { /** Card heading. */ title: React.ReactNode; /** One or two lines under the title. */ description?: React.ReactNode; /** Small icon above the title. */ icon?: React.ReactNode; /** Visual behind the content (illustration, mini UI). It brightens slightly on hover. */ background?: React.ReactNode; /** Makes the whole card a link. */ href?: string; /** Link component to render when `href` is set, e.g. Next.js `Link`. */ linkAs?: React.ElementType; /** Call-to-action label that slides up on hover / focus. Shown only on links. */ cta?: React.ReactNode; /** Columns to span (clamped to the grid's `columns`). */ colSpan?: 1 | 2 | 3 | 4; /** Rows to span. */ rowSpan?: 1 | 2 | 3; /** Heading element for the title. */ titleAs?: "h2" | "h3" | "h4"; } /** * A bento cell. On hover (and keyboard focus) the border and background * visual brighten and the content lifts to reveal a call to action. With * `href` the whole card is one link, so it is a single Tab stop with a clear * focus ring. * * The reveal is pure CSS transform/opacity, so nothing re-renders on hover. Touch screens (no hover) always show the * call to action; reduced motion keeps the fades and drops the movement. */ export function BentoCard({ title, description, icon, background, href, linkAs, cta = "Learn more", colSpan = 1, rowSpan = 1, titleAs: Title = "h3", className, children, ...props }: BentoCardProps) { const columns = React.useContext(BentoContext); const span = Math.min(colSpan, columns); const isLink = Boolean(href); const Comp: React.ElementType = isLink ? (linkAs ?? "a") : "div"; // Hover-only hidden states live under (hover: hover), so touch screens show everything. const hoverReveal = "[@media(hover:hover)]:translate-y-(--bento-shift) group-hover/bento:translate-y-0 group-focus-visible/bento:translate-y-0"; return ( <Comp data-slot="bento-card" href={href} className={cn( "group/bento relative isolate flex flex-col justify-end overflow-hidden rounded-xl border border-white/10 bg-card p-6 text-card-foreground", "transition-[border-color,box-shadow] duration-200 ease-out hover:border-white/20", // Movement distances as variables so reduced motion can zero them in one place. "[--bento-shift:2.75rem] [--bento-nudge:0.125rem]", "motion-reduce:[--bento-shift:0px] motion-reduce:[--bento-nudge:0px]", isLink && "outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", colSpans[span], rowSpans[rowSpan], className )} {...props} > {background && ( <div aria-hidden className={cn( "pointer-events-none absolute inset-0 -z-10 opacity-70", "transition-opacity duration-200 ease-out", "group-hover/bento:opacity-100 group-focus-visible/bento:opacity-100", "[mask-image:linear-gradient(to_bottom,#000_35%,transparent_85%)]" )} > {background} </div> )} <div className={cn( "relative transition-transform duration-250 ease-out", // A card-colored scrim under the text so background visuals never collide with it. background && "before:pointer-events-none before:absolute before:-inset-x-6 before:-bottom-6 before:-top-10 before:-z-10 before:bg-linear-to-t before:from-card before:from-60% before:to-transparent", isLink && cta && hoverReveal )} > {icon && ( <div className="mb-3 inline-flex size-10 items-center justify-center rounded-lg border border-white/10 bg-white/[0.04] text-white/80 [&_svg]:size-5"> {icon} </div> )} <Title className="text-lg font-semibold tracking-tight text-white">{title}</Title> {description && <p className="mt-1.5 max-w-prose text-sm leading-relaxed text-white/60">{description}</p>} {children} {isLink && cta && ( <span className={cn( "mt-4 inline-flex h-7 items-center gap-1.5 text-sm font-medium text-foreground", "transition-opacity duration-200 [@media(hover:hover)]:opacity-0 group-hover/bento:opacity-100 group-focus-visible/bento:opacity-100" )} > {cta} <ArrowRight aria-hidden className="size-4 transition-transform duration-200 group-hover/bento:translate-x-(--bento-nudge)" /> </span> )} </div> </Comp> ); }
Usage
import Link from "next/link"
import { Globe, Rocket } from "lucide-react"
import { BentoCard, BentoGrid } from "@/components/dusk/bento-grid/bento-grid"
export function Features() {
return (
<BentoGrid columns={3}>
<BentoCard
colSpan={2}
href="/docs/deploy"
linkAs={Link}
icon={<Rocket />}
title="Deploy in one command"
description="Push to main and you're live everywhere."
cta="Read the guide"
/>
<BentoCard
rowSpan={2}
href="/docs/edge"
linkAs={Link}
icon={<Globe />}
title="Global edge"
description="Served from the closest region."
/>
</BentoGrid>
)
}Examples
Four columns, static cards
columns sets the column count on large screens (tablets get two, phones one). Cards without href are plain containers: they keep the hover border and background change but show no call to action. Change the row height with an auto-rows-* class.
AI assistant
Ask questions about your codebase and get answers with links to the exact lines.
Postgres
Serverless, branching.
GPU jobs
Pay per second.
Branch previews
Every pull request gets a live URL.
SOC 2
Audited yearly.
Alerts
Slack, email, webhooks.
Monorepo aware
Only rebuild what changed.
import { Bell, Bot, Cpu, Database, GitBranch, Layers, ShieldCheck } from "lucide-react";
import { BentoCard, BentoGrid } from "@/components/dusk/bento-grid/bento-grid";
function Dots() {
return (
<div className="absolute inset-0 bg-[radial-gradient(rgb(255_255_255/0.08)_1px,transparent_1px)] [background-size:16px_16px]" />
);
}
export default function BentoGridFourColumnsDemo() {
return (
<BentoGrid columns={4} className="max-w-4xl auto-rows-[minmax(11rem,auto)]">
<BentoCard
colSpan={2}
rowSpan={2}
icon={<Bot />}
title="AI assistant"
description="Ask questions about your codebase and get answers with links to the exact lines."
background={<Dots />}
/>
<BentoCard icon={<Database />} title="Postgres" description="Serverless, branching." background={<Dots />} />
<BentoCard icon={<Cpu />} title="GPU jobs" description="Pay per second." background={<Dots />} />
<BentoCard
colSpan={2}
icon={<GitBranch />}
title="Branch previews"
description="Every pull request gets a live URL."
/>
<BentoCard icon={<ShieldCheck />} title="SOC 2" description="Audited yearly." />
<BentoCard icon={<Bell />} title="Alerts" description="Slack, email, webhooks." />
<BentoCard
colSpan={2}
icon={<Layers />}
title="Monorepo aware"
description="Only rebuild what changed."
/>
</BentoGrid>
);
}API Reference
BentoGrid takes columns (2 | 3 | 4, default 3) plus any div attribute. BentoCard takes the props below plus any HTML attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | — | Card heading. |
| description | ReactNode | — | Text under the title. |
| icon | ReactNode | — | Small icon above the title. |
| background | ReactNode | — | Decorative visual behind the content; it brightens slightly on hover. Rendered aria-hidden. |
| href | string | — | Makes the whole card one link. |
| linkAs | ElementType | "a" | Link component for href, e.g. Next.js Link. |
| cta | ReactNode | "Learn more" | Call to action revealed on hover / focus. Links only; pass null to hide it. |
| colSpan | 1 | 2 | 3 | 4 | 1 | Columns to span from sm up, clamped to the grid's columns. |
| rowSpan | 1 | 2 | 3 | 1 | Rows to span from sm up. |
| titleAs | "h2" | "h3" | "h4" | "h3" | Heading element for the title. |
Accessibility
- A card with href is a single link: one Tab stop whose accessible name is its title, description and call to action. It has a visible focus ring, and focus triggers the same reveal as hover.
- Pick the right heading level with
titleAsso the cards fit your page outline. - The background visual is aria-hidden decoration.
- On touch screens (no hover) the call to action is always visible, so nothing is hidden behind a hover.
- With prefers-reduced-motion nothing slides; the call to action and the brighter background only fade in.
- The reveal is CSS transform and opacity, so hovering never re-renders React.