Site
Page head
The site's page head: the page title as the section head with its lines breaking from 768, a lead in the soft gray, a White and a quiet button (or a control in the White one's place), and an ASCII drift in the right columns or fading in from the edge when centered. The error head is the same with a retry button.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add page-head<script type="module" src="/spyglass-ds/elements/page-head.js"></script>Resources
Templates, writing and docs for building on Acme.
Simple pricing, for every team
Start free. Pay as you grow, and cancel anytime.
Acme for agents
Give any agent live answers from Acme in one step.
Updated May 2026
Terms of service
The terms that apply when you use Acme's products.
Something went wrong
This page did not load. Try again, or start from the homepage.
Usage
The top of an inner page (resources, use cases, legal, coming soon, 404 and error pages); align="centre" for pricing-style pages; control to put a connect menu or a form in the White button's place; visual for your own picture on the right.
Never
- More than one White button: with a control, the White button is left out
- A display-size title: page heads use the section head (56px at most)
- Moving drifts: the texture holds still
Adds with it: ascii-drift, button
Props
The web component takes the same as attributes or properties (<spyglass-page-head>); title is heading there.
<PageHead>
| Prop | Type | Default |
|---|---|---|
id | string Names the heading (`<id>-heading`) the section is labeled by. | 'page' |
lines | string[] The title, one string per line (lines break from 768). | |
eyebrow | string The capital label over the title. | |
lead | string The lead paragraph. | |
primary | PageAction The White button. Left out when there is a `control`. | |
secondary | PageAction The quiet button after it. | |
control | ReactNode A control in the White button's place (a connect menu, a sign-up form). | |
pair | boolean On phones, hide the control and turn the quiet button White (the site's MCP pair). False keeps both. | true |
align | 'margin' | 'centre' margin (copy left, drift right) or centre. | 'margin' |
visual | ReactNode Your own picture in the right columns instead of the drift (margin only). | |
drift | boolean The ASCII drift in the right columns when there is no `visual` (margin only). | true |
className | string |
<ErrorHead>
| Prop | Type | Default |
|---|---|---|
content | ErrorHeadContent | |
onRetry | () => void Called when the White button is pressed. | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { PageHead } from '@/react/components/site/PageHead'
// An inner page's head: the copy on the left, the ASCII drift on the right, a White and a quiet button.
export default function Margin() {
return <PageHead id="resources" lines={['Resources']} lead="Templates, writing and docs for building on Acme." primary={{ label: 'Get a free API key', href: '#' }} secondary={{ label: 'Read the docs', href: '#' }} />
}<!-- An inner page's head: the copy on the left, the ASCII drift on the right, a White and a quiet button. -->
<spyglass-page-head head-id="resources" lines='["Resources"]' lead="Templates, writing and docs for building on Acme." primary='{"label":"Get a free API key","href":"#"}' secondary='{"label":"Read the docs","href":"#"}'></spyglass-page-head>import { PageHead } from '@/react/components/site/PageHead'
// A centered head over two lines, the texture fading in from the right edge from 1024.
export default function Centre() {
return <PageHead id="pricing" lines={['Simple pricing,', 'for every team']} lead="Start free. Pay as you grow, and cancel anytime." align="centre" />
}<!-- A centered head over two lines, the texture fading in from the right edge from 1024. -->
<spyglass-page-head head-id="pricing" lines='["Simple pricing,","for every team"]' lead="Start free. Pay as you grow, and cancel anytime." align="centre"></spyglass-page-head>import { ConnectMenu } from '@/react/components/site/ConnectMenu'
import { PageHead } from '@/react/components/site/PageHead'
// A use case's head with the connect menu in the White button's place; on phones it steps aside for a White button.
export default function Control() {
return <PageHead id="agents" lines={['Acme for agents']} lead="Give any agent live answers from Acme in one step." control={<ConnectMenu />} secondary={{ label: 'Get a free API key', href: '#' }} />
}<!-- A use case's head with the connect menu in the White button's place; on phones it steps aside for a White button. -->
<spyglass-page-head head-id="agents" lines='["Acme for agents"]' lead="Give any agent live answers from Acme in one step." secondary='{"label":"Get a free API key","href":"#"}'><spyglass-connect-menu slot="control"></spyglass-connect-menu></spyglass-page-head>import { PageHead } from '@/react/components/site/PageHead'
// A legal page's head: an eyebrow over the title and the lead, no buttons.
export default function Eyebrow() {
return <PageHead id="terms" eyebrow="Updated May 2026" lines={['Terms of service']} lead="The terms that apply when you use Acme's products." />
}<!-- A legal page's head: an eyebrow over the title and the lead, no buttons. -->
<spyglass-page-head head-id="terms" eyebrow="Updated May 2026" lines='["Terms of service"]' lead="The terms that apply when you use Acme's products."></spyglass-page-head>'use client'
import { ErrorHead } from '@/react/components/site/ErrorHead'
// The error page's head: try again, or go home.
export default function Error() {
return <ErrorHead onRetry={() => {}} />
}<!-- The error page's head: try again, or go home. -->
<spyglass-error-head></spyglass-error-head>Source
import type { ReactNode } from 'react'
import { Button } from '@/react/components/ui/Button'
import { asciiDriftStyleObject } from '@/lib/ascii-drift'
import { cn } from '@/react/lib/cn'
// The site's page head (pages/PageHead, PageHead.module.css): the page title as the section head (32/36, 44/48 at 768,
// 56/60 at 1024), each of `lines` on its own line from 768, a lead under it in the soft gray (20/28, 640px at most) and
// the actions 40px below: a White button and a quiet one, or a `control` (a connect menu, a form) in the White
// button's place. 64px above (96 at 768, 128 at 1024) and 80 below (96 at 768). `align="margin"` (the default) puts the
// copy in the left 7 of 12 columns from 768 and an ASCII drift (the texture's cluster crop fading out from the middle)
// in the other 5, or your own `visual` there (shown on phones too); `align="centre"` centers it all and, from 1024,
// fades the texture's mass crop in from the right edge. An `eyebrow` sits 16px over the title in the label style.
// Nothing moves. On phones the buttons take the full width, one under the other; beside a control, the control steps
// aside there and the quiet button turns White (the site's MCP pair).
export interface PageAction {
label: string
href: string
}
export interface PageHeadProps {
/** Names the heading (`<id>-heading`) the section is labeled by. */
id?: string
/** The title, one string per line (lines break from 768). */
lines: string[]
/** The capital label over the title. */
eyebrow?: string
/** The lead paragraph. */
lead?: string
/** The White button. Left out when there is a `control`. */
primary?: PageAction
/** The quiet button after it. */
secondary?: PageAction
/** A control in the White button's place (a connect menu, a sign-up form). */
control?: ReactNode
/** On phones, hide the control and turn the quiet button White (the site's MCP pair). False keeps both. */
pair?: boolean
/** margin (copy left, drift right) or centre. */
align?: 'margin' | 'centre'
/** Your own picture in the right columns instead of the drift (margin only). */
visual?: ReactNode
/** The ASCII drift in the right columns when there is no `visual` (margin only). */
drift?: boolean
className?: string
}
export function PageHead({ id = 'page', lines, eyebrow, lead, primary, secondary, control, align = 'margin', visual, drift = true, pair = true, className }: PageHeadProps) {
const centre = align === 'centre'
const actions = control || primary || secondary
const paired = Boolean(control) && pair
return (
<section data-ds="page-head" aria-labelledby={`${id}-heading`} data-align={align} className={cn('relative isolate overflow-x-clip pt-16 pb-20 text-fg md:pt-24 md:pb-24 lg:pt-32', className)}>
{centre ? <span aria-hidden="true" className="pointer-events-none absolute top-0 right-0 -z-1 hidden h-full w-[calc(50%-var(--ds-page-head-drift-clear))] select-none lg:block" style={asciiDriftStyleObject('mass', 'right')} /> : null}
<div className={cn('mx-auto flex w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] flex-col gap-6 px-(--ds-layout-gutter)', centre && 'items-center text-center')}>
{eyebrow ? <p className="-mb-2 type-label text-fg-muted">{eyebrow}</p> : null}
<h1 id={`${id}-heading`} className="max-w-full type-section">
{lines.map((line, i) => <span key={`${i}-${line}`} className="inline md:block">{line}{i < lines.length - 1 ? ' ' : null}</span>)}
</h1>
<div className={cn('grid w-full grid-cols-[minmax(0,1fr)] gap-12', !centre && 'md:grid-cols-[minmax(0,7fr)_minmax(0,5fr)] md:items-start lg:gap-16')}>
<div className={cn(centre && 'flex flex-col items-center text-center')}>
{lead ? <p className="max-w-measure type-body-lg text-pretty text-fg-soft">{lead}</p> : null}
{actions ? (
<div className={cn('mt-10 flex flex-col gap-3 md:flex-row md:flex-wrap', centre && 'self-stretch md:self-auto md:justify-center')}>
{control ? <div className={paired ? 'contents max-md:hidden' : 'contents'}>{control}</div> : null}
{!control && primary ? <Button href={primary.href}>{primary.label}</Button> : null}
{secondary && !paired ? <Button href={secondary.href} variant="secondary">{secondary.label}</Button> : null}
{secondary && paired ? (
<>
<div className="contents max-md:hidden"><Button href={secondary.href} variant="secondary">{secondary.label}</Button></div>
<div className="contents md:hidden"><Button href={secondary.href}>{secondary.label}</Button></div>
</>
) : null}
</div>
) : null}
</div>
{!centre && (visual || drift) ? (
<div className={cn('relative isolate min-w-0', visual ? 'block' : 'hidden md:block md:min-h-40 md:self-stretch')}>
{visual ?? <span aria-hidden="true" className="pointer-events-none absolute inset-x-0 -inset-y-16 -z-1 select-none" style={asciiDriftStyleObject('cluster')} />}
</div>
) : null}
</div>
</div>
</section>
)
}
export default PageHeadimport { PageHead, type PageAction } from '@/react/components/site/PageHead'
import { Button } from '@/react/components/ui/Button'
// The site's error head (pages/PageHead/ErrorHead): the page head with no drift, the title in one line, the lead, and
// a White "Try again" button (`onRetry`) beside the quiet way home.
export interface ErrorHeadContent {
lines: string[]
lead: string
retry: string
home: PageAction
}
export const errorHeadContent: ErrorHeadContent = {
lines: ['Something went wrong'],
lead: 'This page did not load. Try again, or start from the homepage.',
retry: 'Try again',
home: { label: 'Go to the homepage', href: '/' },
}
export interface ErrorHeadProps {
content?: ErrorHeadContent
/** Called when the White button is pressed. */
onRetry?: () => void
className?: string
}
export function ErrorHead({ content: c = errorHeadContent, onRetry, className }: ErrorHeadProps) {
return (
<div data-ds="error-head" className="contents">
<PageHead
id="error"
lines={[c.lines.join(' ')]}
lead={c.lead}
drift={false}
pair={false}
control={<Button onClick={onRetry}>{c.retry}</Button>}
secondary={c.home}
className={className}
/>
</div>
)
}
export default ErrorHead// 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 { asciiDriftStyle } from '@/lib/ascii-drift'
import '@/elements/components/ui/button'
import styles from 'virtual:tw'
// PageHead.tsx as <spyglass-page-head>: the page title as the section head (each of `lines` on its own line from 768),
// a lead in the soft gray and the actions 40px below (a White button and a quiet one, or what is in the `control` slot
// in the White button's place). `align="margin"` puts an ASCII drift (or the `visual` slot) in the right 5 of 12
// columns from 768; `align="centre"` centers it all and fades the texture in from the right edge from 1024. Nothing moves.
export interface PageAction { label: string; href: string }
/**
* @summary The page head: title, lead, actions and the ASCII drift.
* @slot control - A control in the White button's place (a connect menu, a form).
* @slot visual - Your own picture in the right columns instead of the drift (margin only).
*/
export class PageHead extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="page-head"]'))
static properties = {
headId: { attribute: 'head-id' },
lines: { type: Array },
eyebrow: {},
lead: {},
primary: { type: Object },
secondary: { type: Object },
align: { reflect: true },
drift: { type: Boolean, converter: { fromAttribute: (v: string | null) => v !== 'false' } },
pair: { type: Boolean, converter: { fromAttribute: (v: string | null) => v !== 'false' } },
}
/** Names the heading (`<head-id>-heading`) the section is labeled by (React's `id`). */
headId = 'page'
/** The title, one string per line (lines break from 768). */
lines: string[] = []
/** The capital label over the title. */
eyebrow?: string
lead?: string
/** The White button ({ label, href }); left out when the control slot is filled. */
primary?: PageAction
/** The quiet button after it ({ label, href }). */
secondary?: PageAction
/** margin (copy left, drift right) or centre. */
align: 'margin' | 'centre' = 'margin'
/** The ASCII drift in the right columns when the visual slot is empty (margin only). */
drift = true
/** On phones, hide the control and turn the quiet button White (the site's MCP pair); pair="false" keeps both. */
pair = true
render() {
const centre = this.align === 'centre'
const lines = this.lines ?? []
const control = this.hasSlot('control')
const visual = this.hasSlot('visual')
const actions = control || this.primary || this.secondary
const paired = control && this.pair
return html`<section data-ds="page-head" aria-labelledby=${`${this.headId}-heading`} data-align=${this.align} class="relative isolate overflow-x-clip pt-16 pb-20 text-fg md:pt-24 md:pb-24 lg:pt-32">${centre ? html`<span aria-hidden="true" class="pointer-events-none absolute top-0 right-0 -z-1 hidden h-full w-[calc(50%-var(--ds-page-head-drift-clear))] select-none lg:block" style=${asciiDriftStyle('mass', 'right')}></span>` : nothing}<div class=${`mx-auto flex w-full max-w-[calc(var(--ds-layout-content)+2*var(--ds-layout-gutter))] flex-col gap-6 px-(--ds-layout-gutter) ${centre ? 'items-center text-center' : ''}`.trim()}>${this.eyebrow ? html`<p class="-mb-2 type-label text-fg-muted">${this.eyebrow}</p>` : nothing}<h1 id=${`${this.headId}-heading`} class="max-w-full type-section">${lines.map((line, i) => html`<span class="inline md:block">${line}${i < lines.length - 1 ? ' ' : nothing}</span>`)}</h1><div class=${`grid w-full grid-cols-[minmax(0,1fr)] gap-12 ${centre ? '' : 'md:grid-cols-[minmax(0,7fr)_minmax(0,5fr)] md:items-start lg:gap-16'}`.trim()}><div class=${centre ? 'flex flex-col items-center text-center' : ''}>${this.lead ? html`<p class="max-w-measure type-body-lg text-pretty text-fg-soft">${this.lead}</p>` : nothing}${actions ? html`<div class=${`mt-10 flex flex-col gap-3 md:flex-row md:flex-wrap ${centre ? 'self-stretch md:self-auto md:justify-center' : ''}`.trim()}>${control ? html`<div class=${paired ? 'contents max-md:hidden' : 'contents'}><slot name="control"></slot></div>` : nothing}${!control && this.primary ? html`<spyglass-button href=${this.primary.href}>${this.primary.label}</spyglass-button>` : nothing}${this.secondary && !paired ? html`<spyglass-button href=${this.secondary.href} variant="secondary">${this.secondary.label}</spyglass-button>` : nothing}${this.secondary && paired ? html`<div class="contents max-md:hidden"><spyglass-button href=${this.secondary.href} variant="secondary">${this.secondary.label}</spyglass-button></div><div class="contents md:hidden"><spyglass-button href=${this.secondary.href}>${this.secondary.label}</spyglass-button></div>` : nothing}</div>` : nothing}</div>${!centre && (visual || this.drift) ? html`<div class=${`relative isolate min-w-0 ${visual ? 'block' : 'hidden md:block md:min-h-40 md:self-stretch'}`}>${visual ? html`<slot name="visual"></slot>` : html`<span aria-hidden="true" class="pointer-events-none absolute inset-x-0 -inset-y-16 -z-1 select-none" style=${asciiDriftStyle('cluster')}></span>`}</div>` : nothing}</div></div></section>`
}
}
define('page-head', PageHead)import { html } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import '@/elements/components/site/page-head'
import '@/elements/components/ui/button'
import styles from 'virtual:tw'
// ErrorHead.tsx as <spyglass-error-head>: the page head with no drift, the title in one line, the lead, a White
// "Try again" button (fires `retry`) beside the quiet way home. `content` as JSON: { lines, lead, retry, home }.
export interface ErrorHeadContent { lines: string[]; lead: string; retry: string; home: { label: string; href: string } }
export const errorHeadContent: ErrorHeadContent = {
lines: ['Something went wrong'],
lead: 'This page did not load. Try again, or start from the homepage.',
retry: 'Try again',
home: { label: 'Go to the homepage', href: '/' },
}
/**
* @summary The error page's head: try again or go home.
* @fires retry - When the White button is pressed.
*/
export class ErrorHead extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('spyglass-page-head'))
static properties = { content: { type: Object } }
content: ErrorHeadContent = errorHeadContent
render() {
const c = this.content ?? errorHeadContent
return html`<div data-ds="error-head" class="contents"><spyglass-page-head head-id="error" .lines=${[c.lines.join(' ')]} .lead=${c.lead} .drift=${false} .pair=${false} .secondary=${c.home}><spyglass-button slot="control" @click=${() => this.emit('retry')}>${c.retry}</spyglass-button></spyglass-page-head></div>`
}
}
define('error-head', ErrorHead)Reference: Site pages/PageHead (PageHead.tsx, ErrorHead.tsx, PageHead.module.css) and ui/AsciiDrift: 64px above (96 at 768, 128 at 1024), 80 below (96 at 768); .t-head title; 24px between the title and the body; .t-lead in --text-2 at 640px; actions 40px below, 12px apart, stacked on phones; margin: 7fr and 5fr columns from 768 (48px apart, 64 from 1024), the cluster crop at -64px top and bottom, at least 160px tall; centre: the mass crop from the right, from 1024, half the width less 320px.