Feature bento grid
A features section in a bento grid of six tiles in three sizes (wide, tall, small), each with a heading, one sentence and a small interface illustration built in HTML and SVG: a document with live cursors, a version history, an offline queue, page permissions, a search palette with highlighted matches and a live chart. Tiles are data, so you can pass your own illustrations; the grid reflows to two columns and then one.
Source
import type { ReactNode } from "react";
import { CloudOff, Search, CornerDownLeft } from "lucide-react";
import { cn } from "@/lib/utils";
export type BentoTile = {
title: string;
description: string;
/** The tile's picture. Defaults are small interface fragments drawn in HTML and SVG. */
illustration: ReactNode;
/** Grid footprint on large screens. */
size?: "wide" | "tall" | "small";
};
export type FeatureBentoProps = {
title?: string;
description?: string;
tiles?: BentoTile[];
className?: string;
};
const SIZES = {
wide: "md:col-span-2",
tall: "md:row-span-2",
small: "",
};
/* ——— Illustrations: small, real-looking fragments of the product, built from theme tokens. ——— */
function Caret({ name, color }: { name: string; color: string }) {
return (
<span className="relative mx-px inline-block h-[1.15em] w-[2px] align-[-0.2em]" style={{ background: color }}>
<span
className="absolute bottom-full left-0 mb-0.5 whitespace-nowrap rounded-sm rounded-bl-none px-1.5 text-[0.625rem] font-semibold leading-4 text-white"
style={{ background: `color-mix(in oklab, ${color} 78%, black)` }}
>
{name}
</span>
</span>
);
}
function LiveDoc() {
return (
<div data-ui className="rounded-lg bg-background p-5 text-[0.8125rem] leading-relaxed text-foreground ring-1 ring-border sm:p-6">
<p className="text-base font-semibold">Q3 launch runbook</p>
<p className="mt-3 text-muted-foreground">
Freeze merges to <span className="rounded-sm bg-[color-mix(in_oklab,var(--chart-2)_24%,transparent)] px-0.5 text-foreground">main at 14:00 UTC</span>
<Caret name="Jun" color="var(--chart-2)" /> on launch day. The release lead posts the build number in the launch channel before the canary starts.
</p>
<p className="mt-4 text-muted-foreground">
If error rates pass 0.5% for five minutes, roll back with the steps below and page the on-call
<Caret name="Mara" color="var(--chart-1)" /> engineer.
</p>
</div>
);
}
const HISTORY = [
{ who: "Mara Reyes", what: "edited Rollback steps", when: "Today, 14:02", current: true },
{ who: "Jun Li", what: "added 3 comments", when: "Today, 11:40" },
{ who: "Ama Kyei", what: "restored version 12", when: "Yesterday" },
{ who: "Tomasz Olsen", what: "renamed the page", when: "Monday" },
{ who: "Jun Li", what: "linked the incident page", when: "Friday" },
{ who: "Dev Nair", what: "added the canary checklist", when: "Thursday" },
{ who: "Sofia Park", what: "created from a template", when: "12 May" },
];
function VersionHistory() {
return (
<ol data-ui className="relative space-y-5 rounded-lg bg-background p-5 ring-1 ring-border">
<span aria-hidden="true" className="absolute bottom-8 left-[1.6rem] top-8 w-px bg-border" />
{HISTORY.map((item) => (
<li key={item.when} className="relative flex gap-3">
<span
className={cn(
"relative z-10 mt-1 size-2.5 shrink-0 rounded-full ring-4 ring-background",
item.current ? "bg-foreground" : "bg-muted-foreground/40",
)}
/>
<div className="min-w-0 flex-1">
<p className="text-[0.8125rem] leading-snug text-foreground">
<span className="font-medium">{item.who}</span> <span className="text-muted-foreground">{item.what}</span>
</p>
<p className="mt-0.5 text-xs text-muted-foreground">{item.when}</p>
</div>
{!item.current && item.when === "Yesterday" && (
<span className="self-center rounded-md bg-muted px-2 py-1 text-xs font-medium text-foreground">Restore</span>
)}
</li>
))}
</ol>
);
}
function OfflineQueue() {
return (
<div data-ui className="rounded-lg bg-background p-4 ring-1 ring-border">
<div className="flex items-center justify-between">
<span className="inline-flex items-center gap-1.5 rounded-full bg-amber-500/15 px-2 py-0.5 text-xs font-medium text-amber-700 dark:text-amber-300">
<CloudOff className="size-3.5" aria-hidden="true" /> Offline
</span>
<span className="text-xs text-muted-foreground">3 edits waiting</span>
</div>
<ul className="mt-3 space-y-2 text-[0.8125rem]">
{["Site visit checklist", "Pump room notes", "Handover for Tuesday"].map((page, index) => (
<li key={page} className="flex items-center justify-between gap-3 rounded-md bg-muted/60 px-3 py-2">
<span className="truncate text-foreground">{page}</span>
<span className="shrink-0 text-xs text-muted-foreground">{["2 min", "9 min", "21 min"][index]}</span>
</li>
))}
</ul>
</div>
);
}
const PEOPLE = [
{ initials: "MR", name: "Mara Reyes", role: "Can edit", tint: 1 },
{ initials: "JL", name: "Jun Li", role: "Can comment", tint: 2 },
{ initials: "GU", name: "Guest, Larchmont", role: "Can view", tint: 4 },
];
function Permissions() {
return (
<ul data-ui className="space-y-2 rounded-lg bg-background p-3 ring-1 ring-border">
{PEOPLE.map((person) => (
<li key={person.name} className="flex items-center gap-3 rounded-md px-2 py-1.5">
<span
className="grid size-7 shrink-0 place-items-center rounded-full text-[0.625rem] font-semibold text-foreground"
style={{ background: `color-mix(in oklab, var(--chart-${person.tint}) 28%, var(--background))` }}
>
{person.initials}
</span>
<span className="min-w-0 flex-1 truncate text-[0.8125rem] text-foreground">{person.name}</span>
<span className="shrink-0 rounded-md bg-muted px-2 py-1 text-xs text-foreground">{person.role} ▾</span>
</li>
))}
</ul>
);
}
const RESULTS = [
{ title: ["", "Rollback", " steps for the API"], path: "Engineering / Runbooks" },
{ title: ["When to ", "roll back", " a release"], path: "Engineering / Release policy" },
{ title: ["Database ", "rollback", " drill, March"], path: "Platform / Postmortems" },
];
function SearchPalette() {
return (
<div data-ui className="overflow-hidden rounded-lg bg-background ring-1 ring-border">
<div className="flex items-center gap-3 border-b border-border px-4 py-3">
<Search className="size-4 text-muted-foreground" aria-hidden="true" />
<span className="text-sm text-foreground">rollback<span className="ml-px inline-block h-4 w-px translate-y-0.5 bg-foreground" /></span>
<span className="ml-auto text-xs tabular-nums text-muted-foreground">38 ms</span>
</div>
<ul className="p-2">
{RESULTS.map((result, index) => (
<li key={result.path} className={cn("flex items-center gap-3 rounded-md px-3 py-2.5", index === 0 && "bg-muted")}>
<div className="min-w-0 flex-1">
<p className="truncate text-[0.8125rem] text-foreground">
{result.title[0]}
<mark className="rounded-sm bg-[color-mix(in_oklab,var(--chart-4)_35%,transparent)] px-0.5 text-foreground">{result.title[1]}</mark>
{result.title[2]}
</p>
<p className="mt-0.5 truncate text-xs text-muted-foreground">{result.path}</p>
</div>
{index === 0 && <CornerDownLeft className="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />}
</li>
))}
</ul>
</div>
);
}
const SIGNUPS = [22, 28, 25, 34, 31, 40, 46, 43, 52, 58, 55, 66];
function LiveChart() {
const max = 70;
const points = SIGNUPS.map((value, index) => `${(index / (SIGNUPS.length - 1)) * 280 + 10},${100 - (value / max) * 85}`).join(" ");
return (
<div data-ui className="rounded-lg bg-background p-4 ring-1 ring-border">
<div className="flex items-baseline justify-between gap-3">
<p className="text-[0.8125rem] font-medium text-foreground">Weekly sign-ups</p>
<p className="text-xs text-muted-foreground">Synced 2 min ago</p>
</div>
<p className="mt-1 text-2xl font-semibold tracking-tight tabular-nums text-foreground">1,248</p>
<svg viewBox="0 0 300 104" className="mt-2 h-20 w-full" aria-hidden="true" preserveAspectRatio="none">
<polygon points={`10,100 ${points} 290,100`} fill="var(--chart-2)" opacity="0.16" />
<polyline points={points} fill="none" stroke="var(--chart-2)" strokeWidth="2.5" strokeLinejoin="round" vectorEffect="non-scaling-stroke" />
</svg>
</div>
);
}
export const DEFAULT_TILES: BentoTile[] = [
{
title: "Write together without taking turns",
description: "Live cursors, comments and suggestions on the same page, with nothing locked.",
illustration: <LiveDoc />,
size: "wide",
},
{
title: "Every change is kept",
description: "Scroll back through a page's history and restore any version in one click.",
illustration: <VersionHistory />,
size: "tall",
},
{
title: "Works without signal",
description: "Edits made offline sync the moment you reconnect.",
illustration: <OfflineQueue />,
},
{
title: "Permissions per page",
description: "Share one spec with a contractor without opening the workspace.",
illustration: <Permissions />,
},
{
title: "Finds the page before you finish typing",
description: "Search covers titles, text and comments across every space, typically in under 50 ms.",
illustration: <SearchPalette />,
size: "wide",
},
{
title: "Charts that stay current",
description: "Embed a live chart from your data source and it refreshes on its own.",
illustration: <LiveChart />,
},
];
export function FeatureBento({
title = "Specs, notes and runbooks in one editor",
description = "Paperlark keeps a team's written work in one place, and stays quick enough that people use it.",
tiles = DEFAULT_TILES,
className,
}: FeatureBentoProps) {
return (
<section aria-labelledby="feature-bento-title" className={cn("bg-background px-4 py-20 sm:px-6 lg:px-8 lg:py-28", className)}>
<div className="mx-auto max-w-6xl">
<div className="grid gap-6 lg:grid-cols-2 lg:items-end">
<h2 id="feature-bento-title" className="max-w-xl text-balance text-4xl font-semibold tracking-[-0.035em] text-foreground sm:text-5xl">
{title}
</h2>
<p className="max-w-md text-lg leading-relaxed text-muted-foreground lg:justify-self-end">{description}</p>
</div>
<div className="mt-12 grid gap-4 md:grid-cols-2 lg:mt-16 lg:grid-cols-3">
{tiles.map((tile, index) => (
<article
key={tile.title}
className={cn(
"flex flex-col gap-6 overflow-hidden rounded-xl bg-muted/60 p-5 sm:p-6 dark:bg-muted/30",
SIZES[tile.size ?? "small"],
// The last tile closes the row on two-column screens.
index === tiles.length - 1 && tiles.length % 2 === 0 && "md:max-lg:col-span-2",
)}
>
<div>
<h3 className="text-lg font-semibold tracking-tight text-foreground">{tile.title}</h3>
<p className="mt-1.5 max-w-md text-sm leading-relaxed text-muted-foreground">{tile.description}</p>
</div>
<div className="mt-auto" aria-hidden="true">{tile.illustration}</div>
</article>
))}
</div>
</div>
</section>
);
}
