Components
Bento Card
A card for a bento grid: an icon, a title and a description over a decorative background, with a call to action revealed on hover.
Introduction
A bento grid lays a handful of features out as cards of different sizes instead of one uniform list — a wide card for the headline feature, a tall one next to it, the rest filling in. BentoCard is one cell of that grid.
backgroundis any decorative visual — a pattern, a chart, a mock UI. It sits behind the text at reduced opacity and brightens on hover; it never receives clicks.- The call to action is hidden until hover, so the background stays the point at rest and the card still reads as a link.
BentoGridonly sets up the grid. How many columns a card spans is set on the card itself, withclassName.
Installation
npx shadcn@latest add https://centerui.alwinfau.com/r/bento-card.jsonManual installation
Without the CLI: copy these files into your project and keep the paths, or adjust the imports.
1. Install the dependencies
# bun
bun add tailwind-variants tailwind-merge clsx
# pnpm
pnpm add tailwind-variants tailwind-merge clsx
# npm
npm install tailwind-variants tailwind-merge clsx2. Add the styles
src/types/bento-card-styles.tsShow code
import { tv } from "tailwind-variants";
// Styles for BentoCard. `content` sits a little low and `cta` a little below
// the fold at rest, then trade places on hover — the same up/down swap
// Magic UI's own bento grid popularized, just in centerUI's own tokens.
export const bentoCardStyles = tv({
slots: {
root: "group relative flex flex-col justify-between overflow-hidden rounded-xl border bg-card shadow-sm",
background:
"pointer-events-none absolute inset-0 opacity-60 transition-opacity duration-300 group-hover:opacity-100",
content:
"z-10 flex translate-y-2 transform-gpu flex-col gap-1 p-6 transition-transform duration-300 group-hover:-translate-y-2",
icon: "mb-2 size-8 origin-left text-muted-fg transition-transform duration-300 group-hover:scale-90",
name: "m-0 text-lg leading-snug font-semibold text-fg",
description: "m-0 max-w-[80%] text-sm text-muted-fg",
cta: "z-10 flex translate-y-6 transform-gpu items-center gap-1 p-6 pt-0 text-sm font-medium opacity-0 transition-all duration-300 group-hover:translate-y-0 group-hover:opacity-100",
},
});3. Add the Bento Card file
src/components/ui/bento-card/bento-card.tsxShow code
import type { ComponentType, ReactNode } from "react";
import { ArrowRightIcon } from "@/components/icons";
import { Link } from "@/components/ui/link/link";
import { cn } from "@/lib/cn";
import { bentoCardStyles } from "@/types/bento-card-styles";
const styles = bentoCardStyles();
export interface BentoGridProps {
/** `BentoCard`s, each sized with its own `className` (`col-span-*`, `row-span-*`). */
children: ReactNode;
className?: string;
}
/**
* A grid for `BentoCard`, three columns by default. It has no opinion on how
* many rows there are or which card spans what — set that on each card.
*
* @example
* <BentoGrid className="lg:grid-rows-2">
* <BentoCard className="lg:col-span-2" ... />
* <BentoCard className="lg:row-span-2" ... />
* <BentoCard ... />
* </BentoGrid>
*/
export function BentoGrid({ children, className }: BentoGridProps) {
return (
<div
className={cn(
"grid w-full auto-rows-[16rem] grid-cols-3 gap-4",
className,
)}
>
{children}
</div>
);
}
export interface BentoCardProps {
/** The title. */
name: string;
/** A line under the title. */
description: string;
/** Shown above the title, and shrinks a little on hover. */
Icon: ComponentType<{ className?: string }>;
/** Where the call to action goes. */
href: string;
/** The call to action's label, revealed at the bottom on hover. */
cta: string;
/**
* A decorative visual behind the text — a chart, a pattern, a mock UI. It
* fills the card (position it with `absolute inset-0`) and fades up on
* hover; it never receives clicks, so it can be as busy as it likes.
*/
background?: ReactNode;
/** Sizes the card in the grid: `col-span-*`, `row-span-*`. */
className?: string;
}
/**
* A card for a bento grid: an icon, a title and a description over a
* decorative background, with a call to action that only shows up on hover
* so the background stays the point at rest. It has no behavior of its own
* beyond the link, so it works in Server Components.
*
* @example
* <BentoCard
* name="Themeable"
* description="Every color is a token."
* Icon={PaletteIcon}
* href="/docs/theming"
* cta="Read the docs"
* background={<div className="absolute inset-0 pattern-stripes" />}
* />
*/
export function BentoCard({
name,
className,
background,
Icon,
description,
href,
cta,
}: BentoCardProps) {
return (
<div className={cn(styles.root(), className)}>
<div className={styles.background()}>{background}</div>
<div className={styles.content()}>
<Icon className={styles.icon()} />
<h3 className={styles.name()}>{name}</h3>
<p className={styles.description()}>{description}</p>
</div>
<div className={styles.cta()}>
<Link href={href} variant="hover" showIcon={false}>
{cta}
</Link>
<ArrowRightIcon className="size-3.5" />
</div>
</div>
);
}4. Use it
import { BentoCard, BentoGrid } from "@/components/ui/bento-card/bento-card";Anatomy
A grid of cards, each with its own icon, title, description, background and call to action.
<BentoGrid className="lg:grid-rows-2">
<BentoCard
name="Themeable"
description="Every color is a token."
Icon={PaletteIcon}
href="/docs/theming"
cta="Read the docs"
background={<div className="absolute inset-0" />}
className="lg:col-span-2"
/>
{/* more cards, each sized with its own className */}
</BentoGrid>| Part | Rendered as | Notes |
|---|---|---|
| BentoGrid | div | The grid. Three columns by default; set rows and gaps with className. |
| BentoCard | div | One cell: an icon, a title, a description, a background and a call to action. |
Examples
Usage
Three cards, one of them wide and one tall, each with its own decorative background — a pattern, the hero's own grid, and a soft glow.
Sizing
BentoGrid is three columns by default. A card spans more of them the same way any grid item does: col-span and row-span, in className.
{/* Three columns by default. Size a card with className, on the card itself */}
<BentoCard className="lg:col-span-2" ... /> {/* wide */}
<BentoCard className="lg:row-span-2" ... /> {/* tall, needs lg:grid-rows-2 on BentoGrid */}
<BentoCard /* a plain 1x1 cell */ ... />Component API
Bento Card is made of the parts below.
BentoGrid
| Prop | Type | Default |
|---|---|---|
| children | ReactNode | - (required) |
| className | string | - |
BentoCard
| Prop | Type | Default |
|---|---|---|
| name | string | - (required) |
| description | string | - (required) |
| Icon | ComponentType<{ className?: string }> | - (required) |
| href | string | - (required) |
| cta | string | - (required) |
| background | ReactNode | - |
| className | string | - |