Blocks
Hero block
The top of a page as the slides, posts and ads set it: a Funnel Display headline, a line of DM Sans and one White button on Black, with the light flowing in and the media (a search bar, a row of creatives) under the copy.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add hero-block<script type="module" src="/spyglass-ds/elements/hero-block.js"></script>The only creative search engine.
AI search across millions of creatives. Ask a question and get instant, structured results.
The only creative search engine.
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.
Usage
The first thing on a website page. Left with a search bar on a band of the light (the ad), centered under the light field (the offer post), or right-aligned over creatives on the curved strip (the deck cover).
Never
- A headline that does not end with a period, or in title case
- Two White buttons
- The light boxed in the middle of the copy, recolored or moving
- Text over the creatives
light sets where the light flows: field from the top edge, corner from the bottom right, band across the media and strip above it, or none. texture adds the ASCII texture behind it. The headline takes inline nodes in React (the deck's creatives between the words) and a headline slot in the web component.
Adds with it: ascii-texture, brand-light
Props
The web component takes the same as attributes or properties (<spyglass-hero-block>); title is heading there.
<HeroBlock>
| Prop | Type | Default |
|---|---|---|
headline | ReactNode | |
body | ReactNode A line or two of DM Sans under the headline. | |
eyebrow | ReactNode A label in capitals above the headline. | |
actions | ReactNode Buttons (one White primary). | |
placement | HeroPlacement left, center or right. | 'left' |
light | HeroLight Where the light flows: field, corner, band, strip or none. | 'field' |
seed | number The light's (and the texture's) seed. | 0 |
texture | boolean The ASCII texture behind everything. | false |
size | HeroSize section (the site's page head, by default) or display (the larger display line). | 'section' |
children | ReactNode The media under the copy. | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { Button } from '@/react/components/ui/Button'
import { SearchBar } from '@/react/components/product/SearchBar'
import { HeroBlock } from '@/react/components/blocks/HeroBlock'
// The ad's top: the headline and the line, the search bar across a band of the light.
export default function Search() {
return (
<HeroBlock
headline="The only creative search engine."
body="AI search across millions of creatives. Ask a question and get instant, structured results."
actions={<Button href="#pricing">Get 50% off</Button>}
light="band"
seed={2}
texture
>
<SearchBar placeholder="Show me UGC ads for skincare brands using before/after hooks" label="Search creatives" />
</HeroBlock>
)
}<!-- The ad's top: the headline and the line, the search bar across a band of the light. -->
<spyglass-hero-block headline="The only creative search engine." body="AI search across millions of creatives. Ask a question and get instant, structured results." light="band" seed="2" texture>
<spyglass-button slot="actions" href="#pricing">Get 50% off</spyglass-button>
<spyglass-search-bar placeholder="Show me UGC ads for skincare brands using before/after hooks" aria-label="Search creatives"></spyglass-search-bar>
</spyglass-hero-block>import { HeroBlock } from '@/react/components/blocks/HeroBlock'
import { CreativeRow } from '@/react/components/site/CreativeRow'
// The third deck cover: the headline at the top right, creatives over the curved strip.
const items = [
{ brand: 'Acme Studio', tone: 2 as const },
{ brand: 'Acme Fit', tone: 3 as const },
{ brand: 'Acme Drinks', tone: 4 as const },
{ brand: 'Acme Skin', tone: 1 as const },
{ brand: 'Acme Studio', tone: 3 as const },
{ brand: 'Acme Drinks', tone: 2 as const },
{ brand: 'Acme Fit', tone: 4 as const },
]
export default function Strip() {
return (
<HeroBlock headline="The only creative search engine." placement="right" light="strip" seed={0} texture>
<CreativeRow items={items} className="mt-32 max-sm:mt-16" />
</HeroBlock>
)
}<!-- The third deck cover: the headline at the top right, creatives over the curved strip. -->
<spyglass-hero-block headline="The only creative search engine." placement="right" light="strip" seed="0" texture>
<spyglass-creative-row class="mt-32 max-sm:mt-16" items='[{"brand":"Acme Studio","tone":2},{"brand":"Acme Fit","tone":3},{"brand":"Acme Drinks","tone":4},{"brand":"Acme Skin","tone":1},{"brand":"Acme Studio","tone":3},{"brand":"Acme Drinks","tone":2},{"brand":"Acme Fit","tone":4}]'></spyglass-creative-row>
</spyglass-hero-block>import { Button } from '@/react/components/ui/Button'
import { HeroBlock } from '@/react/components/blocks/HeroBlock'
// Centered under the light field, as the offer post sets it.
export default function Centered() {
return (
<HeroBlock
headline="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."
actions={<><Button href="#pricing">Get 50% off</Button><Button href="#product" variant="secondary">Explore the product</Button></>}
placement="center"
light="field"
seed={0}
/>
)
}<!-- Centered under the light field, as the offer post sets it. -->
<spyglass-hero-block headline="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." placement="center" light="field" seed="0">
<spyglass-button slot="actions" href="#pricing">Get 50% off</spyglass-button>
<spyglass-button slot="actions" href="#product" variant="secondary">Explore the product</spyglass-button>
</spyglass-hero-block>Source
import type { ReactNode } from 'react'
import { AsciiTexture } from '@/react/components/visuals/AsciiTexture'
import { BrandLight } from '@/react/components/visuals/BrandLight'
import { cn } from '@/react/lib/cn'
// The top of a page as the site sets it: a Funnel Display headline at 450 (the site's .t-head, 32/36 on phones, 44/48
// at 768, 56/60 from 1024; `size="display"` is the .t-display line, 48 to 112), a #D4D4D4 20/28 lead no wider than
// 640px and the actions, on Black with the light and, if asked, the ASCII texture behind. The children are
// the media under the copy (a search bar, a creative row, a ring). The placements in the assets:
// left the ad and the first deck cover: copy at the top left, the media under it
// center the offer post and the Creator plan ad: everything centered, the light field above
// right the third deck cover: the headline at the top right, the creatives on a curved strip below
// `light` picks where the light flows: `field` from the top edge (fading out before the copy, never a hard edge),
// `corner` in from the corners (on phones, the field above the copy), `band` and `strip` behind the media (a band of the light across it, the curved strip
// running under it). The texture keeps clear of the copy. Nothing moves.
export type HeroPlacement = 'left' | 'center' | 'right'
export type HeroLight = 'field' | 'corner' | 'band' | 'strip' | 'none'
export type HeroSize = 'section' | 'display'
export interface HeroBlockProps {
headline: ReactNode
/** A line or two of DM Sans under the headline. */
body?: ReactNode
/** A label in capitals above the headline. */
eyebrow?: ReactNode
/** Buttons (one White primary). */
actions?: ReactNode
/** left, center or right. */
placement?: HeroPlacement
/** Where the light flows: field, corner, band, strip or none. */
light?: HeroLight
/** The light's (and the texture's) seed. */
seed?: number
/** The ASCII texture behind everything. */
texture?: boolean
/** section (the site's page head, by default) or display (the larger display line). */
size?: HeroSize
/** The media under the copy. */
children?: ReactNode
className?: string
}
const ALIGN: Record<HeroPlacement, string> = {
left: 'items-start text-left',
center: 'items-center text-center',
right: 'items-end text-right',
}
// Where the texture keeps clear of the copy, in its 1440x900 frame: the copy's side of the block.
const CLEAR: Record<HeroPlacement, { x: number; y: number; w: number; h: number }[]> = {
left: [{ x: 0, y: 0, w: 920, h: 720 }],
center: [{ x: 200, y: 80, w: 1040, h: 680 }],
right: [{ x: 520, y: 0, w: 920, h: 720 }],
}
export function HeroBlock({ headline, body, eyebrow, actions, placement = 'left', light = 'field', seed = 0, texture = false, size = 'section', children, className }: HeroBlockProps) {
const media = light === 'band' || light === 'strip'
return (
<section data-ds="hero-block" className={cn('relative isolate overflow-hidden bg-surface text-fg', className)}>
{texture && <AsciiTexture seed={seed} width={1440} height={900} density={0.4} clear={CLEAR[placement] ?? CLEAR.left} cover className="absolute inset-0 -z-10 size-full" />}
{light === 'field' && <BrandLight variant="field" seed={seed} ground={false} cover className="absolute inset-x-0 top-0 -z-10 h-80 mask-b-from-40% max-sm:h-48" />}
{light === 'corner' && <BrandLight variant="corner" seed={seed} ground={false} cover className="absolute inset-0 -z-10 size-full max-sm:hidden" />}
{light === 'corner' && <BrandLight variant="field" seed={seed} ground={false} cover className="absolute inset-x-0 top-0 -z-10 h-48 mask-b-from-40% sm:hidden" />}
<div className={cn('mx-auto flex w-full max-w-page-wide flex-col gap-6 px-12 max-sm:px-4', ALIGN[placement] ?? ALIGN.left, light === 'field' ? 'pt-72 max-sm:pt-44' : light === 'corner' ? 'pt-24 max-sm:pt-44' : 'pt-24 max-sm:pt-16', children ? 'pb-12 max-sm:pb-10' : 'pb-24 max-sm:pb-16')}>
{eyebrow && <p className="type-label text-fg-muted">{eyebrow}</p>}
<h1 className={cn('max-w-4xl text-balance', size === 'display' ? 'type-display-fluid' : 'type-section')}>{headline}</h1>
{body && <p className="max-w-measure type-body-lg text-fg-soft">{body}</p>}
{actions && <div className="mt-2 flex flex-wrap gap-3">{actions}</div>}
</div>
{children && (
<div className={cn('relative', media ? 'py-14 max-sm:py-10' : 'pb-24 max-sm:pb-16')}>
{light === 'band' && <BrandLight variant="band" seed={seed} ground={false} cover className="absolute inset-0 -z-10 size-full" />}
{light === 'strip' && <BrandLight variant="curved-strip" seed={seed} ground={false} cover className="absolute inset-0 -z-10 size-full" />}
<div className="mx-auto w-full max-w-page-wide px-12 max-sm:px-4">{children}</div>
</div>
)}
</section>
)
}
export default HeroBlock// 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 '@/elements/components/visuals/ascii-texture'
import '@/elements/components/visuals/brand-light'
import styles from 'virtual:tw'
// HeroBlock.tsx as <spyglass-hero-block>: the Funnel Display headline (`headline`, or a `headline` slot for inline
// creatives), `body`, `eyebrow`, the `actions` slot and the media in the default slot, on Black with the light
// (`light`: field, corner, band, strip or none) and the `texture`. `placement` is left, center or right.
export type HeroPlacement = 'left' | 'center' | 'right'
export type HeroLight = 'field' | 'corner' | 'band' | 'strip' | 'none'
const ALIGN: Record<HeroPlacement, string> = {
left: 'items-start text-left',
center: 'items-center text-center',
right: 'items-end text-right',
}
const CLEAR: Record<HeroPlacement, { x: number; y: number; w: number; h: number }[]> = {
left: [{ x: 0, y: 0, w: 920, h: 720 }],
center: [{ x: 200, y: 80, w: 1040, h: 680 }],
right: [{ x: 520, y: 0, w: 920, h: 720 }],
}
/**
* @summary The top of a page: headline, a line, actions and media, over the light.
* @slot - The media under the copy.
* @slot headline - The headline with inline creatives (instead of the attribute).
* @slot actions - Buttons.
*/
export class HeroBlock extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="hero-block"]'))
static properties = { headline: {}, body: {}, eyebrow: {}, placement: {}, light: {}, seed: { type: Number }, texture: { type: Boolean }, size: {} }
headline = ''
/** A line or two of DM Sans under the headline. */
body?: string
/** A label in capitals above the headline. */
eyebrow?: string
/** left, center or right (not `align`, which the browser reads as a text alignment). */
placement: HeroPlacement = 'left'
/** field, corner, band, strip or none. */
light: HeroLight = 'field'
seed = 0
/** The ASCII texture behind everything. */
texture = false
/** section (the site's page head, by default) or display (the larger display line). */
size: 'section' | 'display' = 'section'
render() {
const light = this.light
const media = light === 'band' || light === 'strip'
const kids = this.hasSlot()
const top = ['mx-auto flex w-full max-w-page-wide flex-col gap-6 px-12 max-sm:px-4', ALIGN[this.placement] ?? ALIGN.left, light === 'field' ? 'pt-72 max-sm:pt-44' : light === 'corner' ? 'pt-24 max-sm:pt-44' : 'pt-24 max-sm:pt-16', kids ? 'pb-12 max-sm:pb-10' : 'pb-24 max-sm:pb-16'].join(' ')
return html`<section data-ds="hero-block" class="relative isolate overflow-hidden bg-surface text-fg">${this.texture ? html`<spyglass-ascii-texture seed=${this.seed} width="1440" height="900" density="0.4" .clear=${CLEAR[this.placement] ?? CLEAR.left} cover class="absolute inset-0 -z-10 size-full"></spyglass-ascii-texture>` : nothing}${light === 'field' ? html`<spyglass-brand-light variant="field" seed=${this.seed} ground="false" cover class="absolute inset-x-0 top-0 -z-10 h-80 mask-b-from-40% max-sm:h-48"></spyglass-brand-light>` : nothing}${light === 'corner' ? html`<spyglass-brand-light variant="corner" seed=${this.seed} ground="false" cover class="absolute inset-0 -z-10 size-full max-sm:hidden"></spyglass-brand-light><spyglass-brand-light variant="field" seed=${this.seed} ground="false" cover class="absolute inset-x-0 top-0 -z-10 h-48 mask-b-from-40% sm:hidden"></spyglass-brand-light>` : nothing}<div class=${top}>${this.eyebrow ? html`<p class="type-label text-fg-muted">${this.eyebrow}</p>` : nothing}<h1 class=${this.size === 'display' ? 'max-w-4xl text-balance type-display-fluid' : 'max-w-4xl text-balance type-section'}>${this.hasSlot('headline') ? html`<slot name="headline"></slot>` : this.headline}</h1>${this.body ? html`<p class="max-w-measure type-body-lg text-fg-soft">${this.body}</p>` : nothing}${this.hasSlot('actions') ? html`<div class="mt-2 flex flex-wrap gap-3"><slot name="actions"></slot></div>` : nothing}</div>${kids ? html`<div class=${['relative', media ? 'py-14 max-sm:py-10' : 'pb-24 max-sm:pb-16'].join(' ')}>${light === 'band' ? html`<spyglass-brand-light variant="band" seed=${this.seed} ground="false" cover class="absolute inset-0 -z-10 size-full"></spyglass-brand-light>` : nothing}${light === 'strip' ? html`<spyglass-brand-light variant="curved-strip" seed=${this.seed} ground="false" cover class="absolute inset-0 -z-10 size-full"></spyglass-brand-light>` : nothing}<div class="mx-auto w-full max-w-page-wide px-12 max-sm:px-4"><slot></slot></div></div>` : nothing}</section>`
}
}
define('hero-block', HeroBlock)Reference: Figma page 8: Ad, The only creative search engine (headline at 64,168, the line at 312, the search bar on a Light band); Post, Offer and Ad, Creator plan offer (centered under the Light field); Pitch deck cover, Curved strip (headline at the top right, creatives over the curved strip).