Blocks
Bento block
Features as a bento grid: #262626 cards with the 4px corner, a title and a line, some wide or tall, an optional picture.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add bento-block<script type="module" src="/spyglass-ds/elements/bento-block.js"></script>What you get
One index for every creative your team needs.
Search every network
Meta, TikTok, Instagram and YouTube in one index.
Alerts
Know the day a brand launches.
Boards
Save and share with one link.
API and MCP
Your agents read the same index.
History
Every ad since the day it ran.
Usage
A features section with a few lead features and smaller ones around them.
Never
- More than one picture per card
- Cards in a spectrum color
Props
The web component takes the same as attributes or properties (<spyglass-bento-block>); title is heading there.
<BentoBlock>
| Prop | Type | Default |
|---|---|---|
items | BentoItem[] | |
title | ReactNode | |
body | ReactNode A line under the title. | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { BentoBlock } from '@/react/components/blocks/BentoBlock'
// Acme's features as a bento grid, wide and tall cards among them.
const items = [
{
"title": "Search every network",
"body": "Meta, TikTok, Instagram and YouTube in one index.",
"span": "wide"
},
{
"title": "Alerts",
"body": "Know the day a brand launches.",
"span": "tall"
},
{
"title": "Boards",
"body": "Save and share with one link."
},
{
"title": "API and MCP",
"body": "Your agents read the same index."
},
{
"title": "History",
"body": "Every ad since the day it ran.",
"span": "wide"
}
] as const
export default function Features() {
return <BentoBlock title="What you get" body="One index for every creative your team needs." items={[...items]} />
}<!-- Acme's features as a bento grid, wide and tall cards among them. -->
<spyglass-bento-block heading="What you get" body="One index for every creative your team needs." items='[{"title":"Search every network","body":"Meta, TikTok, Instagram and YouTube in one index.","span":"wide"},{"title":"Alerts","body":"Know the day a brand launches.","span":"tall"},{"title":"Boards","body":"Save and share with one link."},{"title":"API and MCP","body":"Your agents read the same index."},{"title":"History","body":"Every ad since the day it ran.","span":"wide"}]'></spyglass-bento-block>Source
import type { ReactNode } from 'react'
import { cn } from '@/react/lib/cn'
// Features as a bento grid, as the site's feature cards sit: #262626 cards with the 4px corner, 24px in, a Funnel
// Display 24/28 title and a #D4D4D4 line, an optional picture above the words. Six columns from 1024 (a card takes two,
// a `wide` one four, a `tall` one two rows), two from 768, one on phones. Nothing moves.
export interface BentoItem {
title: string
body?: string
/** A picture above the words (src). */
image?: string
/** wide (four columns), tall (two rows) or normal. */
span?: 'normal' | 'wide' | 'tall'
}
export interface BentoBlockProps {
items: BentoItem[]
title?: ReactNode
/** A line under the title. */
body?: ReactNode
className?: string
}
const SPAN = { normal: 'lg:col-span-2', wide: 'md:col-span-2 lg:col-span-4', tall: 'lg:col-span-2 lg:row-span-2' }
export function BentoBlock({ items, title, body, className }: BentoBlockProps) {
return (
<section data-ds="bento-block" className={cn('grid gap-10 text-fg', className)}>
{(title || body) && (
<div className="grid max-w-3xl gap-6">
{title && <h2 className="type-section">{title}</h2>}
{body && <p className="max-w-measure type-body-lg text-fg-soft">{body}</p>}
</div>
)}
<ul role="list" className="m-0 grid list-none grid-cols-1 gap-4 p-0 md:grid-cols-2 lg:auto-rows-[minmax(200px,auto)] lg:grid-cols-6">
{items.map((i) => (
<li key={i.title} className={cn('flex flex-col gap-4 overflow-hidden rounded-container bg-surface-raised p-6', SPAN[i.span ?? 'normal'])}>
{i.image && <img src={i.image} alt="" className="aspect-[16/9] w-full rounded-ds-sm object-cover" />}
<div className="mt-auto grid gap-2">
<h3 className="type-heading-3">{i.title}</h3>
{i.body && <p className="type-body text-fg-soft">{i.body}</p>}
</div>
</li>
))}
</ul>
</section>
)
}
export default BentoBlock// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]
export function cn(...values: ClassValue[]): string {
const out: string[] = []
for (const v of values) {
if (!v) continue
if (Array.isArray(v)) {
const s = cn(...v)
if (s) out.push(s)
}
else out.push(v)
}
return out.join(' ')
}import { html, nothing } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import styles from 'virtual:tw'
// BentoBlock.tsx as <spyglass-bento-block>: features as a bento grid from `items` ({ title, body, image, span }), with
// an optional `heading` (React's `title`) and `body`.
export interface BentoItem { title: string; body?: string; image?: string; span?: 'normal' | 'wide' | 'tall' }
const SPAN = { normal: 'lg:col-span-2', wide: 'md:col-span-2 lg:col-span-4', tall: 'lg:col-span-2 lg:row-span-2' }
/**
* @summary Features as a bento grid of cards.
*/
export class BentoBlock extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="bento-block"]'))
static properties = { items: { type: Array }, heading: {}, body: {} }
items: BentoItem[] = []
/** The heading (React's `title`). */
heading?: string
body?: string
render() {
return html`<section data-ds="bento-block" class="grid gap-10 text-fg">${this.heading || this.body ? html`<div class="grid max-w-3xl gap-6">${this.heading ? html`<h2 class="type-section">${this.heading}</h2>` : nothing}${this.body ? html`<p class="max-w-measure type-body-lg text-fg-soft">${this.body}</p>` : nothing}</div>` : nothing}<ul role="list" class="m-0 grid list-none grid-cols-1 gap-4 p-0 md:grid-cols-2 lg:auto-rows-[minmax(200px,auto)] lg:grid-cols-6">${(this.items ?? []).map((i) => html`<li class=${`flex flex-col gap-4 overflow-hidden rounded-container bg-surface-raised p-6 ${SPAN[i.span ?? 'normal'] ?? SPAN.normal}`}>${i.image ? html`<img src=${i.image} alt="" class="aspect-[16/9] w-full rounded-ds-sm object-cover">` : nothing}<div class="mt-auto grid gap-2"><h3 class="type-heading-3">${i.title}</h3>${i.body ? html`<p class="type-body text-fg-soft">${i.body}</p>` : nothing}</div></li>`)}</ul></section>`
}
}
define('bento-block', BentoBlock)Reference: Built from the site's feature cards (V2Features: --surface cards, --radius-s, 24px in, h5 titles) on a six-column grid.