Pages
404 page
The site's 404 page: the header, the page head with the title, what happened in a plain sentence, the White way home and the quiet way to the docs, the ASCII drift in the right columns, and the footer.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add not-found-page<script type="module" src="/spyglass-ds/elements/not-found-page.js"></script>Page not found
This page does not exist or has moved. Start from the homepage, or find what you need in the docs.
Usage
A website's not-found page. Edit lib/pages/not-found.ts or pass content.
Never
- A joke or an error code as the title
- More than one White button in a view
- A search or other controls in the head: two ways on, home and the docs
sections lists the sections to show, in order (head); a key left out is not shown. menus passes the header menus (the live card's picture, the use cases' shots).
Adds with it: ascii-trail, creative-card, page-head, site-footer, site-header
Props
The web component takes the same as attributes or properties (<spyglass-not-found-page>); title is heading there.
<NotFoundPage>
| Prop | Type | Default |
|---|---|---|
content | NotFoundContent | |
menus | HeaderMenus The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default. | |
sections | readonly NotFoundSection[] The sections to show, in order; all of them in the page order by default (leave one out to omit it). | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { NotFoundPage } from '@/react/components/pages/NotFoundPage'
// The 404 page as the site sets it, with Acme's footer line.
export default function Page() {
return <NotFoundPage />
}<!-- The 404 page as the site sets it, with Acme's footer line. -->
<spyglass-not-found-page></spyglass-not-found-page>Source
import { SiteHeader } from '@/react/components/site/SiteHeader'
import { AsciiTrail } from '@/react/components/visuals/AsciiTrail'
import { PageHead } from '@/react/components/site/PageHead'
import { SiteFooter } from '@/react/components/blocks/SiteFooter'
import { notFoundContent, type NotFoundContent, notFoundSections, type NotFoundSection } from '@/lib/pages/not-found'
import { cn } from '@/react/lib/cn'
import { pageSections } from '@/lib/image'
import { Fragment, type ReactNode } from 'react'
import type { HeaderMenus } from '@/lib/site-header'
// The site's 404 page (app/not-found.tsx): the header, the page head with its title, the plain sentence, the White way
// home and the quiet way to the docs, the ASCII drift in the right columns, and the footer. As the last section on the
// page the head keeps the site's section padding under it (56px, 76 at 768, 84 at 1024), so it sits in a box that
// takes back what the page head keeps below. `content` replaces the copy (lib/pages/not-found.ts).
export interface NotFoundPageProps {
content?: NotFoundContent
/** The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default. */
menus?: HeaderMenus
/** The sections to show, in order; all of them in the page order by default (leave one out to omit it). */
sections?: readonly NotFoundSection[]
className?: string
}
export function NotFoundPage({ content: c = notFoundContent, menus, sections, className }: NotFoundPageProps) {
const parts: Record<NotFoundSection, ReactNode> = {
head: (
<div className="-mb-6 md:-mb-5 lg:-mb-3">
<PageHead id="not-found" lines={c.lines} lead={c.lead} primary={c.primary} secondary={c.secondary} />
</div>
),
}
return (
<div data-ds="not-found-page" className={cn('isolate bg-surface text-fg', className)}>
<AsciiTrail mode="page" />
<SiteHeader menus={menus} links={c.shell.header.nav} secondary={c.shell.header.secondary} />
<main id="main">
{pageSections(notFoundSections, sections).map((k) => <Fragment key={k}>{parts[k]}</Fragment>)}
</main>
<SiteFooter columns={c.shell.footer.columns} legal={c.shell.footer.legal} />
</div>
)
}
export default NotFoundPage// The 404 page's copy (site content/pages/errors.ts): the title, what happened in a plain sentence and the two ways on.
// Both flavors read this file.
// The header's five pages and the sign-in, the footer's six columns and Acme's legal line.
const shell = {
header: {
nav: [
{ label: 'Products', href: '/products' },
{ label: 'Use cases', href: '/use-cases' },
{ label: 'Enterprise', href: '/enterprise' },
{ label: 'Resources', href: '/resources' },
{ label: 'Pricing', href: '/pricing' },
],
secondary: { label: 'Sign in', href: '/sign-in' },
},
footer: {
columns: [
{ title: 'Products', wide: true, links: [{ label: 'Brands and creators', href: '/products/brand-search' }, { label: 'Media archive', href: '/products/media-search' }, { label: 'Collaborations', href: '/products/creator-collabs' }, { label: 'Creative insights', href: '/products/creative-insights' }, { label: 'Realtime search', href: '/products/realtime-search' }, { label: 'Coming soon', href: '/products' }] },
{ title: 'Use cases', wide: true, links: [{ label: 'Build your own', href: '/use-cases/build' }, { label: 'Creative research', href: '/use-cases/creative-research' }, { label: 'Paid ads', href: '/use-cases/paid-ads' }, { label: 'Organic social', href: '/use-cases/organic-social' }, { label: 'Competitive analysis', href: '/use-cases/competitive-analysis' }, { label: 'Creator sourcing', href: '/use-cases/creator-sourcing' }] },
{ title: 'Resources', links: [{ label: 'Templates', href: '/templates' }, { label: 'Docs', href: '/docs' }, { label: 'Blog', href: '/resources/blog' }, { label: 'Articles', href: '/resources/articles' }] },
{ title: 'Company', links: [{ label: 'Enterprise', href: '/enterprise' }, { label: 'About', href: '/about' }, { label: 'Careers', href: '/about#careers' }, { label: 'Talk to us', href: '/enterprise#talk' }, { label: 'Sign in', href: '/sign-in' }] },
{ title: 'Legal', links: [{ label: 'Terms', href: '/terms' }, { label: 'Privacy', href: '/privacy' }] },
{ title: 'Community', links: [{ label: 'X', href: 'https://x.com' }, { label: 'LinkedIn', href: 'https://linkedin.com' }, { label: 'Instagram', href: 'https://instagram.com' }] },
],
legal: '© 2026 Acme Inc.',
},
}
// The careers template still reads these two (its header links and its footer row).
const header = {
nav: [
{ label: 'Product', href: '/product' },
{ label: 'Pricing', href: '/pricing' },
{ label: 'Changelog', href: '/changelog' },
{ label: 'Blog', href: '/blog' },
],
secondary: { label: 'Sign in', href: '/sign-in' },
cta: { label: 'Get 50% off', href: '/pricing' },
}
const footer = {
domain: 'spyglass.so',
links: [
{ label: 'Product', href: '/product' },
{ label: 'Pricing', href: '/pricing' },
{ label: 'About', href: '/about' },
{ label: 'Changelog', href: '/changelog' },
{ label: 'Blog', href: '/blog' },
{ label: 'Terms', href: '/legal' },
],
}
export const notFoundContent = {
shell,
lines: ['Page not found'],
lead: 'This page does not exist or has moved. Start from the homepage, or find what you need in the docs.',
primary: { label: 'Go to the homepage', href: '/' },
secondary: { label: 'Read the docs', href: '/docs' },
header,
footer,
}
export type NotFoundContent = typeof notFoundContent
/** The not found page's sections in order; pass `sections` to reorder them or leave some out. */
export const notFoundSections = ['head'] as const
export type NotFoundSection = (typeof notFoundSections)[number]// 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 } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { notFoundContent, type NotFoundContent, notFoundSections, type NotFoundSection } from '@/lib/pages/not-found'
import '@/elements/components/site/site-header'
import '@/elements/components/site/page-head'
import '@/elements/components/blocks/site-footer'
import '@/elements/components/visuals/ascii-trail'
import styles from 'virtual:tw'
import { pageSections } from '@/lib/image'
import { headerMenus, type HeaderMenus } from '@/lib/site-header'
// NotFoundPage.tsx as <spyglass-not-found-page>: the site's 404 page, the header, the page head (title, the plain
// sentence, the way home and the docs, the ASCII drift) and the footer. `content` replaces the copy.
/**
* @summary The 404 page.
*/
export class NotFoundPage extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="not-found-page"]'))
static properties = { content: { type: Object }, menus: { type: Object }, sections: { type: Array } }
/** The page's copy (lib/pages/not-found.ts by default). */
content: NotFoundContent = notFoundContent
/** The header menus' content, pictures included (the live card's `picture`, the use cases' `shots`); Acme by default. */
menus?: HeaderMenus
/** The sections to show, in order (a list of names); all of them in the page order by default. */
sections?: NotFoundSection[]
render() {
const c = this.content ?? notFoundContent
const parts: Record<NotFoundSection, unknown> = {
head: html`<div class="-mb-6 md:-mb-5 lg:-mb-3"><spyglass-page-head head-id="not-found" .lines=${c.lines} .lead=${c.lead} .primary=${c.primary} .secondary=${c.secondary}></spyglass-page-head></div>`,
}
return html`<div data-ds="not-found-page" class="isolate bg-surface text-fg"><spyglass-ascii-trail mode="page"></spyglass-ascii-trail><spyglass-site-header .menus=${this.menus ?? headerMenus} .links=${c.shell.header.nav} .secondary=${c.shell.header.secondary}></spyglass-site-header><main id="main">${pageSections(notFoundSections, this.sections).map((k) => parts[k])}</main><spyglass-site-footer .columns=${c.shell.footer.columns} legal=${c.shell.footer.legal}></spyglass-site-footer></div>`
}
}
define('not-found-page', NotFoundPage)Reference: Site app/not-found.tsx and content/pages/errors.ts: Header, PageHead (margin, the cluster drift) with the homepage and the docs, Footer; as main's last section the head keeps --section-y under it (56, 76 at 768, 84 at 1024).