404 page section
A 404 where the two fours are giant letters that lean away from your cursor, the zero is a spinning dashed ring, and search plus popular links help you get back.
"use client";
import {
useRef,
useState,
type CSSProperties,
type PointerEvent as ReactPointerEvent,
} from "react";
import "./not-found.css";
const LINKS = [
{ label: "Home", hint: "Start over", href: "#home" },
{ label: "Pricing", hint: "Plans and FAQ", href: "#pricing" },
{ label: "Docs", hint: "Guides and API", href: "#docs" },
{ label: "Contact", hint: "We reply within a day", href: "#contact" },
];
/**
* NotFound
* - Pointer position is stored as --mx/--my (−1 to 1) on the section; the digits read it in CSS.
* Writing CSS variables directly avoids a React re-render on every mouse move.
* - The search box filters a few popular pages; wire it to your real search.
*/
export function NotFound({
theme = "light",
path = "/pricing-2024-old",
}: {
theme?: "light" | "dark";
path?: string;
}) {
const root = useRef<HTMLElement>(null);
const [q, setQ] = useState("");
const shown = LINKS.filter((l) =>
`${l.label} ${l.hint}`.toLowerCase().includes(q.trim().toLowerCase()),
);
const onMove = (e: ReactPointerEvent<HTMLElement>) => {
if (e.pointerType !== "mouse" || !root.current) return;
const r = root.current.getBoundingClientRect();
root.current.style.setProperty(
"--mx",
(((e.clientX - r.left) / r.width) * 2 - 1).toFixed(3),
);
root.current.style.setProperty(
"--my",
(((e.clientY - r.top) / r.height) * 2 - 1).toFixed(3),
);
};
return (
<section
ref={root}
className="gu-404"
data-theme={theme}
onPointerMove={onMove}
style={{ "--mx": 0, "--my": 0 } as CSSProperties}
>
<div className="gu-404__digits" aria-hidden="true">
<span className="gu-404__four">4</span>
<span className="gu-404__zero">
<svg viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" />
</svg>
</span>
<span className="gu-404__four gu-404__four--r">4</span>
</div>
<div className="gu-404__body">
<h1>This page wandered off.</h1>
<p>
We couldn't find <code>{path}</code>. It may have moved, or the
link has a typo.
</p>
<label className="gu-404__search">
<span className="gu-sr">Search the site</span>
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="11" cy="11" r="6.5" />
<path d="m16 16 4.5 4.5" />
</svg>
<input
type="search"
placeholder="Search pages…"
value={q}
onChange={(e) => setQ(e.target.value)}
/>
</label>
<ul className="gu-404__links">
{shown.map((l) => (
<li key={l.label}>
<a href={l.href}>
<b>{l.label}</b>
<span>{l.hint}</span>
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="M5 10h10m-4-4 4 4-4 4" />
</svg>
</a>
</li>
))}
{!shown.length && (
<li className="gu-404__none">
No page matches “{q}”. Try “docs” or “pricing”.
</li>
)}
</ul>
</div>
</section>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: 404 page section
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A 404 page section: giant "4 ◌ 4" on the left where the fours lean away from the cursor in 3D and the zero is a slowly spinning dashed ring; on the right a plain-spoken headline, the missing path, a search field and popular links.
## Layout and look
- Cream (dark Ink) section, two columns 1.2fr / 1fr, min-height 620px; stacks under 760px.
- Digits: clamp(112px, 24cqi, 320px), weight 900, tracking -0.08em; the fours are orange #ff5a1f; the zero is an SVG circle with a 9px dashed Ink stroke (18/9 dashes, round caps).
- Headline "This page wandered off." (clamp 32–58px, weight 900), muted text with the path in a code chip.
- Search: 56px pill. Links: 52px rows (bold label, muted hint, arrow) separated by hairlines; hover slides the row right 8px, tints it orange and nudges the arrow.
## Behavior and motion
1. Pointer position over the section → --mx/--my in −1…1, written straight to CSS variables. Fours: rotateY(−22° × mx) rotateX(14° × my) plus a ±10px slide; the ring follows a little (600ms cubic-bezier(0.16, 1, 0.3, 1)).
2. The ring spins 360° every 14s.
3. Touch devices (hover: none): the fours sway on their own.
4. Search filters the links; no match shows a hint.
## Accessibility
- The digits are aria-hidden; the page has a real h1. The search input has a hidden label.
- prefers-reduced-motion: everything still.
## Props
theme, path. Edit LINKS.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### NotFound.tsx
```tsx
"use client";
import {
useRef,
useState,
type CSSProperties,
type PointerEvent as ReactPointerEvent,
} from "react";
import "./not-found.css";
const LINKS = [
{ label: "Home", hint: "Start over", href: "#home" },
{ label: "Pricing", hint: "Plans and FAQ", href: "#pricing" },
{ label: "Docs", hint: "Guides and API", href: "#docs" },
{ label: "Contact", hint: "We reply within a day", href: "#contact" },
];
/**
* NotFound
* - Pointer position is stored as --mx/--my (−1 to 1) on the section; the digits read it in CSS.
* Writing CSS variables directly avoids a React re-render on every mouse move.
* - The search box filters a few popular pages; wire it to your real search.
*/
export function NotFound({
theme = "light",
path = "/pricing-2024-old",
}: {
theme?: "light" | "dark";
path?: string;
}) {
const root = useRef<HTMLElement>(null);
const [q, setQ] = useState("");
const shown = LINKS.filter((l) =>
`${l.label} ${l.hint}`.toLowerCase().includes(q.trim().toLowerCase()),
);
const onMove = (e: ReactPointerEvent<HTMLElement>) => {
if (e.pointerType !== "mouse" || !root.current) return;
const r = root.current.getBoundingClientRect();
root.current.style.setProperty(
"--mx",
(((e.clientX - r.left) / r.width) * 2 - 1).toFixed(3),
);
root.current.style.setProperty(
"--my",
(((e.clientY - r.top) / r.height) * 2 - 1).toFixed(3),
);
};
return (
<section
ref={root}
className="gu-404"
data-theme={theme}
onPointerMove={onMove}
style={{ "--mx": 0, "--my": 0 } as CSSProperties}
>
<div className="gu-404__digits" aria-hidden="true">
<span className="gu-404__four">4</span>
<span className="gu-404__zero">
<svg viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" />
</svg>
</span>
<span className="gu-404__four gu-404__four--r">4</span>
</div>
<div className="gu-404__body">
<h1>This page wandered off.</h1>
<p>
We couldn't find <code>{path}</code>. It may have moved, or the
link has a typo.
</p>
<label className="gu-404__search">
<span className="gu-sr">Search the site</span>
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="11" cy="11" r="6.5" />
<path d="m16 16 4.5 4.5" />
</svg>
<input
type="search"
placeholder="Search pages…"
value={q}
onChange={(e) => setQ(e.target.value)}
/>
</label>
<ul className="gu-404__links">
{shown.map((l) => (
<li key={l.label}>
<a href={l.href}>
<b>{l.label}</b>
<span>{l.hint}</span>
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="M5 10h10m-4-4 4 4-4 4" />
</svg>
</a>
</li>
))}
{!shown.length && (
<li className="gu-404__none">
No page matches “{q}”. Try “docs” or “pricing”.
</li>
)}
</ul>
</div>
</section>
);
}
```
### not-found.css
```css
/* NotFound: change these colors to match your brand. */
.gu-404 {
--bg: #f3eee3;
--card: #fbf8f2;
--text: #0e0e10;
--muted: #57534b;
--line: rgb(14 14 16 / 0.14);
--accent: #ff5a1f;
--focus: #2b35ff;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
container-type: inline-size;
display: grid;
grid-template-columns: 1.2fr 1fr;
align-items: center;
gap: clamp(24px, 5%, 72px);
min-height: 620px;
padding: clamp(32px, 6%, 80px) clamp(18px, 5%, 64px);
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: system-ui, sans-serif;
}
.gu-404[data-theme="dark"] {
--bg: #0e0e10;
--card: #18181b;
--text: #f3eee3;
--muted: #aea89c;
--line: rgb(243 238 227 / 0.14);
--focus: #d7ff3a;
}
.gu-404__digits {
display: flex;
align-items: center;
justify-content: center;
font-size: clamp(7rem, 24cqi, 20rem);
font-weight: 900;
letter-spacing: -0.08em;
line-height: 0.8;
perspective: 800px;
}
.gu-404__four {
display: inline-block;
color: var(--accent);
/* Lean away from the pointer, with a little depth */
transform: rotateY(calc(var(--mx) * -22deg)) rotateX(calc(var(--my) * 14deg))
translateX(calc(var(--mx) * -10px));
transition: transform 0.6s var(--ease);
}
.gu-404__four--r {
transform: rotateY(calc(var(--mx) * -22deg)) rotateX(calc(var(--my) * 14deg))
translateX(calc(var(--mx) * 10px));
}
.gu-404__zero {
display: grid;
place-items: center;
width: 0.72em;
height: 0.9em;
margin: 0 0.02em;
}
.gu-404__zero svg {
width: 100%;
overflow: visible;
translate: calc(var(--mx) * 14px) calc(var(--my) * 10px);
transition: translate 0.6s var(--ease);
}
.gu-404__zero circle {
fill: none;
stroke: var(--text);
stroke-width: 9;
stroke-dasharray: 18 9;
stroke-linecap: round;
transform-origin: center;
animation: gu-404-spin 14s linear infinite;
}
@keyframes gu-404-spin {
to {
rotate: 360deg;
}
}
/* Touch screens: the fours sway on their own */
@media (hover: none) {
.gu-404__four {
animation: gu-404-sway 5s ease-in-out infinite;
}
.gu-404__four--r {
animation-delay: -2.5s;
}
}
@keyframes gu-404-sway {
50% {
transform: rotateY(18deg) rotateX(-6deg);
}
}
.gu-404 h1 {
margin: 0 0 12px;
font-size: clamp(2rem, 5cqi, 3.6rem);
font-weight: 900;
letter-spacing: -0.045em;
line-height: 0.95;
}
.gu-404__body > p {
margin: 0 0 22px;
color: var(--muted);
line-height: 1.5;
}
.gu-404 code {
padding: 1px 6px;
border-radius: 6px;
background: var(--line);
color: var(--text);
font-size: 0.9em;
overflow-wrap: anywhere;
}
.gu-404__search {
position: relative;
display: block;
margin-bottom: 12px;
}
.gu-404__search svg {
position: absolute;
top: 50%;
left: 18px;
width: 20px;
translate: 0 -50%;
fill: none;
stroke: var(--muted);
stroke-width: 2;
stroke-linecap: round;
}
.gu-404__search input {
width: 100%;
height: 56px;
padding: 0 18px 0 48px;
border: 1.5px solid var(--line);
border-radius: 999px;
outline: none;
background: var(--card);
color: inherit;
font: inherit;
}
.gu-404__search input:focus {
border-color: var(--focus);
box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent);
}
.gu-404__links {
margin: 0;
padding: 0;
list-style: none;
}
.gu-404__links a {
display: grid;
grid-template-columns: auto 1fr 20px;
align-items: center;
gap: 12px;
min-height: 52px;
padding: 0 8px;
border-bottom: 1px solid var(--line);
color: inherit;
text-decoration: none;
transition:
padding 0.3s var(--ease),
background-color 0.2s;
}
.gu-404__links a:hover {
padding-left: 16px;
background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.gu-404__links a:focus-visible {
outline: 3px solid var(--focus);
outline-offset: -2px;
}
.gu-404__links b {
font-weight: 800;
}
.gu-404__links span {
color: var(--muted);
font-size: 0.88rem;
}
.gu-404__links svg {
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
transition: translate 0.3s var(--ease);
}
.gu-404__links a:hover svg {
translate: 4px 0;
}
.gu-404__none {
padding: 14px 8px;
color: var(--muted);
}
.gu-sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
@container (max-width: 640px) {
/* The root is the container, so it cannot query itself: its children span the full row instead */
.gu-404 > * {
grid-column: 1 / -1;
}
}
@media (prefers-reduced-motion: reduce) {
.gu-404__four,
.gu-404__four--r,
.gu-404__zero svg {
transform: none;
translate: none;
transition: none;
animation: none;
}
.gu-404__zero circle {
animation: none;
}
}
```
You might also want
Next piece: Activity heatmapBento features grid
Templates, intermediate
Help center FAQ
Templates, intermediate
Integrations orbit
Templates, intermediate