Blocks

Feature grid block

What the product does, as cards: an optional Funnel Display heading and line over a grid of cards on the #262626 fill, each a title and a sentence, three or two across.

Install

React apps get the React files; every other stack gets the web component.

npx spyglass-ds add feature-grid-block
<script type="module" src="/spyglass-ds/elements/feature-grid-block.js"></script>
Three across

Know what changed before your next meeting.

Spyglass follows the brands, creators, and niches that matter to you then turns the changes into a brief you actually want to read.

Understand what is working in any category.

Compare brands, creators, campaigns, and formats to uncover what is gaining traction, what is falling behind, and why.

Search millions of creators in one place.

Spyglass monitors millions of brands and creators across Meta Ads, Instagram, and TikTok.

Two across, under a heading

Why Acme Studio uses it.

Two jobs, done in one place.

One board for the team.

Acme Studio saves every creative it likes to one board the whole team can search.

Alerts that matter.

Acme Studio hears when a tracked brand launches a new ad, the day it goes live.

Usage

The section of a home or product page that says what the product does, one card per job.

Never

  • Icons, colored cards or images inside the cards
  • More than six cards, or a card without a sentence
  • Claims the product does not make

Adds with it: card

Props

The web component takes the same as attributes or properties (<spyglass-feature-grid-block>); title is heading there.

<FeatureGridBlock>

PropTypeDefault
featuresFeature[]
titleReactNode

A heading above the cards.

bodyReactNode

A line under the heading.

columns2 | 3

Cards across on wide screens: 2 or 3.

3
classNamestring

Examples

The same example in React and as web components; both render identically.

react/examples/feature-grid-block/Three.tsx
import { FeatureGridBlock } from '@/react/components/blocks/FeatureGridBlock'
// The three jobs the assets name, three across.

const features = [
  { title: 'Know what changed before your next meeting.', body: 'Spyglass follows the brands, creators, and niches that matter to you then turns the changes into a brief you actually want to read.' },
  { title: 'Understand what is working in any category.', body: 'Compare brands, creators, campaigns, and formats to uncover what is gaining traction, what is falling behind, and why.' },
  { title: 'Search millions of creators in one place.', body: 'Spyglass monitors millions of brands and creators across Meta Ads, Instagram, and TikTok.' },
]

export default function Three() {
  return <FeatureGridBlock features={features} />
}
elements/examples/feature-grid-block/Three.html
<!-- The three jobs the assets name, three across. -->
<spyglass-feature-grid-block features='[{"title":"Know what changed before your next meeting.","body":"Spyglass follows the brands, creators, and niches that matter to you then turns the changes into a brief you actually want to read."},{"title":"Understand what is working in any category.","body":"Compare brands, creators, campaigns, and formats to uncover what is gaining traction, what is falling behind, and why."},{"title":"Search millions of creators in one place.","body":"Spyglass monitors millions of brands and creators across Meta Ads, Instagram, and TikTok."}]'></spyglass-feature-grid-block>
react/examples/feature-grid-block/Two.tsx
import { FeatureGridBlock } from '@/react/components/blocks/FeatureGridBlock'
// An Acme team's two reasons, two across under a heading.

const features = [
  { title: 'One board for the team.', body: 'Acme Studio saves every creative it likes to one board the whole team can search.' },
  { title: 'Alerts that matter.', body: 'Acme Studio hears when a tracked brand launches a new ad, the day it goes live.' },
]

export default function Two() {
  return <FeatureGridBlock title="Why Acme Studio uses it." body="Two jobs, done in one place." features={features} columns={2} />
}
elements/examples/feature-grid-block/Two.html
<!-- An Acme team's two reasons, two across under a heading. -->
<spyglass-feature-grid-block heading="Why Acme Studio uses it." body="Two jobs, done in one place." columns="2" features='[{"title":"One board for the team.","body":"Acme Studio saves every creative it likes to one board the whole team can search."},{"title":"Alerts that matter.","body":"Acme Studio hears when a tracked brand launches a new ad, the day it goes live."}]'></spyglass-feature-grid-block>

Source

react/components/blocks/FeatureGridBlock.tsx
import type { ReactNode } from 'react'
import { Card } from '@/react/components/ui/Card'
import { cn } from '@/react/lib/cn'

// What the product does, as cards: an optional Funnel Display heading and line over a grid of cards on the #262626
// fill, each a title and a sentence (the home page's three cards, as a block). Three across (or two), one on phones.
// No icons and no color: the words carry it.
export interface Feature {
  title: string
  body: string
}

export interface FeatureGridBlockProps {
  features: Feature[]
  /** A heading above the cards. */
  title?: ReactNode
  /** A line under the heading. */
  body?: ReactNode
  /** Cards across on wide screens: 2 or 3. */
  columns?: 2 | 3
  className?: string
}

export function FeatureGridBlock({ features, title, body, columns = 3, className }: FeatureGridBlockProps) {
  return (
    <section data-ds="feature-grid-block" className={cn('grid gap-10 text-fg max-sm:gap-8', className)}>
      {(title || body) && (
        <div className="grid max-w-3xl gap-4">
          {title && <h2 className="type-section">{title}</h2>}
          {body && <p className="type-body-lg text-fg-soft">{body}</p>}
        </div>
      )}
      <div className={cn('grid gap-4 max-md:grid-cols-1', columns === 2 ? 'grid-cols-2' : 'grid-cols-3')}>
        {features.map((f) => <Card key={f.title} title={f.title} description={f.body} />)}
      </div>
    </section>
  )
}

export default FeatureGridBlock
react/lib/cn.ts
// 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(' ')
}
elements/components/blocks/feature-grid-block.ts
import { html, nothing } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import '@/elements/components/ui/card'
import styles from 'virtual:tw'

// FeatureGridBlock.tsx as <spyglass-feature-grid-block>: a `heading` (React's `title`) and a `body` line over cards
// (`features`, a list of { title, body }), three across or two (`columns`), one on phones.
export interface Feature { title: string; body: string }

/**
 * @summary What the product does, as a grid of cards.
 */
export class FeatureGridBlock extends DsElement {
	static styles = [DsElement.styles, styles]
	protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="feature-grid-block"]'))
	static properties = { features: { type: Array }, heading: {}, body: {}, columns: { type: Number } }
	features: Feature[] = []
	/** A heading above the cards (React's `title`). */
	heading?: string
	/** A line under the heading. */
	body?: string
	/** Cards across on wide screens: 2 or 3. */
	columns: 2 | 3 = 3

	render() {
		return html`<section data-ds="feature-grid-block" class="grid gap-10 text-fg max-sm:gap-8">${this.heading || this.body ? html`<div class="grid max-w-3xl gap-4">${this.heading ? html`<h2 class="type-section">${this.heading}</h2>` : nothing}${this.body ? html`<p class="type-body-lg text-fg-soft">${this.body}</p>` : nothing}</div>` : nothing}<div class=${['grid gap-4 max-md:grid-cols-1', this.columns === 2 ? 'grid-cols-2' : 'grid-cols-3'].join(' ')}>${(this.features ?? []).map((f) => html`<spyglass-card heading=${f.title} description=${f.body}></spyglass-card>`)}</div></section>`
	}
}

define('feature-grid-block', FeatureGridBlock)

Reference: Built from the library (card); the home page's three cards (copy from Post, Know what changed; Post, Every market; Ad, One photo).