Bento tile
A feature tile with an optional edge-to-edge visual, a caption, and room for controls or supporting content.
pnpm dlx shadcn@latest add @haze/bento-tile---
import { cn } from "../../../lib/haze/utils";
interface Props {
title: string;
description?: string;
headingLevel?: 2 | 3 | 4;
span?: "quarter" | "third" | "half" | "two-thirds" | "three-quarters" | "full";
variant?: "default" | "info";
class?: string;
bodyClass?: string;
visualClass?: string;
}
const { title, description, headingLevel = 3, span = "third", variant = "default", class: className, bodyClass, visualClass } = Astro.props;
const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const hasVisual = Astro.slots.has("visual");
const spans = {
quarter: "@2xl/bento:col-span-3",
third: "@2xl/bento:col-span-4",
half: "@2xl/bento:col-span-6",
"two-thirds": "@2xl/bento:col-span-8",
"three-quarters": "@2xl/bento:col-span-9",
full: "@md/bento:col-span-full",
};
---
<article class={cn(
"group/tile flex min-w-0 flex-col rounded-2xl border border-border bg-card text-card-foreground",
!hasVisual && "gap-4 p-4 sm:p-5",
variant === "info" && "border-border-strong bg-muted",
spans[span],
className,
)}>
{hasVisual && (
<div class={cn("relative isolate grid min-h-40 min-w-0 flex-1 overflow-clip rounded-t-2xl border-b border-border bg-muted", visualClass)}>
<slot name="visual" />
</div>
)}
<div class={hasVisual ? "flex min-w-0 flex-col gap-3 p-4 sm:p-5 lg:p-6" : "contents"}>
<div class="flex min-w-0 flex-wrap items-start justify-between gap-x-2 gap-y-0.5">
<div class="min-w-0 grow basis-36">
<Heading class={cn("font-medium tracking-tight wrap-anywhere", hasVisual ? "text-lg/6 sm:text-xl/7" : "text-[1.0625rem]/6")}>{title}</Heading>
{description && <p class="mt-1 max-w-prose text-pretty wrap-anywhere text-[0.8125rem]/5 text-muted-foreground">{description}</p>}
</div>
<slot name="accessory" />
</div>
{Astro.slots.has("default") && <div class={cn("grid min-w-0 content-start gap-3", bodyClass)}><slot /></div>}
</div>
</article>When to use
- You need a shared panel treatment across a product mosaic.
- One panel should receive a restrained brand tint.
When not to use
- The whole surface needs to be a single link.
Installation
Add the Haze registry to components.json once, then install Bento tile with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/bento-tilenpx shadcn@latest add @haze/bento-tileyarn dlx shadcn@latest add @haze/bento-tilebunx --bun shadcn@latest add @haze/bento-tileFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| title* | string | – | Visible panel heading. |
| description | string | – | Supporting text below the title. |
| headingLevel | 2 | 3 | 4 | 3 | Heading level in the surrounding document. |
| span | quarter | third | half | two-thirds | three-quarters | full | third | Column span inside Bento Mosaic. Full spans both columns at intermediate widths. |
| variant | default | info | default | Neutral surface, or a raised neutral surface with a stronger border for emphasis. |
| default slot | slot | – | Content or controls in the panel body. |
| visual slot | slot | – | Artwork or a working product sample above the caption. Give meaningful diagrams a text equivalent. |
| accessory slot | slot | – | Compact header detail such as a status. |
| class | string | – | Classes on the article. |
| bodyClass | string | – | Classes on the body grid. |
| visualClass | string | – | Sizing, alignment and surface classes for the visual slot. |
Accessibility
- Pick a heading level that matches the outline.
- Controls keep their native focus order. Hide decorative artwork from assistive technology.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Bento tile" with `npx shadcn@latest add @haze/bento-tile`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import BentoTile from "@/components/haze/ui/bento-tile.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/bento-tile.md
Customize with real content
Adapt the Haze bento-tile ui for our product. Replace the demo values of these props with our real content: title, description, headingLevel, span, variant, default slot, visual slot, accessory slot, class, bodyClass, visualClass. Keep the layout, the heading level rules and these accessibility details: Pick a heading level that matches the outline. Controls keep their native focus order. Hide decorative artwork from assistive technology. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using bento-tile, check it fits: use it when you need a shared panel treatment across a product mosaic.; one panel should receive a restrained brand tint.. Avoid it when the whole surface needs to be a single link.. Alternatives: @haze/card, @haze/bento-mosaic.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.