# Relief Not Found

> A 404 page over a wall of the site's own page names. Type where you were headed and every page that matches rises out of the wall, with the closest ones listed underneath as real links; until then a slow wave rolls past the message.

A 404 Page block from KeyframeUI: a whole landing-page section built around the Relief component, free to install as source with the shadcn CLI. Built with React and Tailwind CSS.

- Live preview: https://keyframeui.com/blocks/not-found-pages/relief-not-found
- Category: 404 Pages
- Built with: [Relief](https://keyframeui.com/components/relief.md)
- npm dependencies: clsx, tailwind-merge

## Installation

Register the @keyframeui registry in `components.json` once per project:

```json
{
  "registries": {
    "@keyframeui": "https://keyframeui.com/r/{name}.json"
  }
}
```

Then add the block. It lands in `components/relief-not-found.tsx`, and the CLI also adds the components it's built with (`components/ui/relief.tsx`) and `lib/utils.ts`, and installs the npm dependencies:

```bash
npx shadcn@latest add @keyframeui/relief-not-found
```

Or install by URL, without registering the namespace:

```bash
npx shadcn@latest add https://keyframeui.com/r/relief-not-found.json
```

## Usage

Put it where the section goes. The copy, links and data sit in constants at the top of the file; edit them there.

```tsx
import { ReliefNotFound } from "@/components/relief-not-found";

export default function Page() {
  return <ReliefNotFound />;
}
```

## Source

```tsx title="components/relief-not-found.tsx"
"use client";

import * as React from "react";

import { Relief, type ReliefEntry } from "@/components/ui/relief";

/* ── Content ─────────────────────────────────────────────────
 * Everything you'd change to make the 404 yours: the message,
 * the two ways out, and your site's pages. The wall is the
 * pages' names; typing raises the ones that match, closer
 * matches higher, and the best few are listed as real links.
 * ─────────────────────────────────────────────────────────── */

/** The wall's inks, low to high: indigo up to amber. */
const INKS = ["#1e1b4b", "#3730a3", "#4f46e5", "#a5b4fc", "#f5f7ff", "#fde68a", "#f59e0b", "#ea580c"];
/** The accent for small text: the match count and the focus ring. Light and dark. */
const ACCENT = { light: "#4f46e5", dark: "#a5b4fc" };

const CODE = "Error 404";
const HEADLINE = "This link went somewhere else.";
const SUBLINE = "The page moved or never existed. Type what you came for and every page that matches rises out of the wall.";
const PLACEHOLDER = "Where were you headed?";
const HOME = { label: "Back to home", href: "/" };
const CONTACT = { label: "Contact support", href: "#contact" };
/** How many matches are listed as links under the box. */
const LIMIT = 4;

/** Your site's pages: the label on the wall, where it lives, and other words people use for it. */
const PAGES: { label: string; href: string; also?: string[] }[] = [
  { label: "Pricing", href: "/pricing", also: ["plans", "cost", "billing"] },
  { label: "Docs", href: "/docs", also: ["documentation", "guide", "help"] },
  { label: "API", href: "/docs/api", also: ["reference", "endpoints", "developer"] },
  { label: "Webhooks", href: "/docs/webhooks", also: ["events", "api", "developer"] },
  { label: "SDKs", href: "/docs/sdks", also: ["libraries", "developer"] },
  { label: "Changelog", href: "/changelog", also: ["releases", "updates", "new"] },
  { label: "Status", href: "/status", also: ["uptime", "outage", "down"] },
  { label: "Security", href: "/security", also: ["soc 2", "privacy", "trust"] },
  { label: "Privacy", href: "/privacy", also: ["gdpr", "data", "policy"] },
  { label: "Terms", href: "/terms", also: ["legal", "policy"] },
  { label: "Careers", href: "/careers", also: ["jobs", "hiring", "work"] },
  { label: "Blog", href: "/blog", also: ["articles", "news"] },
  { label: "Customers", href: "/customers", also: ["case studies", "stories"] },
  { label: "Integrations", href: "/integrations", also: ["connect", "apps", "helpdesk"] },
  { label: "Help center", href: "/help", also: ["support", "faq", "questions"] },
  { label: "Contact", href: "/contact", also: ["support", "sales", "email"] },
  { label: "Book a demo", href: "/demo", also: ["sales", "call", "trial"] },
  { label: "Sign in", href: "/login", also: ["login", "account", "password"] },
  { label: "Sign up", href: "/signup", also: ["register", "trial", "account"] },
  { label: "Billing", href: "/settings/billing", also: ["invoice", "card", "payment"] },
  { label: "Invoices", href: "/settings/invoices", also: ["receipts", "billing"] },
  { label: "Team", href: "/settings/team", also: ["members", "invite", "seats"] },
  { label: "Routing", href: "/product/routing", also: ["assign", "queues"] },
  { label: "Macros", href: "/product/macros", also: ["replies", "templates"] },
  { label: "Reports", href: "/product/reports", also: ["analytics", "dashboards"] },
  { label: "Topics", href: "/product/topics", also: ["trends", "insights"] },
  { label: "Auto-replies", href: "/product/auto-replies", also: ["ai", "answers", "bot"] },
  { label: "SLA", href: "/product/sla", also: ["response time", "targets"] },
  { label: "Partners", href: "/partners", also: ["agencies", "resellers"] },
  { label: "Press", href: "/press", also: ["media", "brand", "logo"] },
  { label: "Brand", href: "/brand", also: ["logo", "assets", "press"] },
  { label: "Templates", href: "/templates", also: ["macros", "replies"] },
  { label: "Mobile app", href: "/mobile", also: ["ios", "android", "phone"] },
  { label: "Data export", href: "/docs/export", also: ["csv", "download", "backup"] },
];

/* ── Section ─────────────────────────────────────────────── */

const WORDS = PAGES.map((p) => ({ text: p.label, tags: p.also ?? [] }));
const BY_LABEL = new Map(PAGES.map((p) => [p.label.toUpperCase(), p]));

/** How well a page answers the query, 0–1: its name beats the other words for it. */
function scorer(query: string) {
  const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
  return (word: ReliefEntry) => {
    const name = word.text.toLowerCase();
    let best = 0;
    for (const term of terms) {
      if (name.startsWith(term)) best = Math.max(best, 1);
      else if (name.includes(term)) best = Math.max(best, 0.78);
      else if (word.tags.some((tag) => tag.startsWith(term))) best = Math.max(best, 0.5);
    }
    return best;
  };
}

export function ReliefNotFound() {
  const [query, setQuery] = React.useState("");
  const [origin, setOrigin] = React.useState<[number, number]>([0.5, 0.6]);
  const wallRef = React.useRef<HTMLDivElement>(null);
  const inputRef = React.useRef<HTMLInputElement>(null);
  const listId = React.useId();
  const trimmed = query.trim();
  const score = React.useMemo(() => scorer(trimmed), [trimmed]);

  const matches = React.useMemo(() => {
    if (!trimmed) return [];
    return WORDS.map((w) => ({ page: BY_LABEL.get(w.text.toUpperCase())!, s: score({ text: w.text.toUpperCase(), tags: w.tags }) }))
      .filter((m) => m.s > 0)
      .sort((a, b) => b.s - a.s);
  }, [trimmed, score]);

  // Matches ripple out from the search box, wherever the layout put it.
  React.useEffect(() => {
    const measure = () => {
      const wall = wallRef.current?.getBoundingClientRect();
      const box = inputRef.current?.getBoundingClientRect();
      if (!wall || !box || !wall.width || !wall.height) return;
      setOrigin([(box.left + box.width / 2 - wall.left) / wall.width, (box.top + box.height / 2 - wall.top) / wall.height]);
    };
    measure();
    const ro = new ResizeObserver(measure);
    if (wallRef.current) ro.observe(wallRef.current);
    return () => ro.disconnect();
  }, []);

  const ring =
    "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)] dark:focus-visible:outline-[var(--accent-dark)]";

  return (
    <section
      style={{ "--accent": ACCENT.light, "--accent-dark": ACCENT.dark } as React.CSSProperties}
      className="bg-[#fafafa] text-zinc-950 dark:bg-[#07080c] dark:text-white"
    >
      <Relief
        ref={wallRef}
        words={WORDS}
        raise={trimmed ? score : null}
        origin={origin}
        inks={INKS}
        fontSize={14}
        label="Pages on this site"
        className="bg-[#fafafa] dark:bg-[#07080c]"
        wordClassName="font-semibold text-zinc-300 dark:text-zinc-800"
      >
        <div className="mx-auto flex max-w-6xl flex-col items-center px-6 py-24 text-center sm:py-32">
          <div data-relief-quiet className="flex w-full max-w-xl flex-col items-center">
            <p className="font-mono text-sm tracking-tight text-zinc-500 dark:text-zinc-400">{CODE}</p>
            <h1 className="mt-4 text-4xl leading-[1.05] font-semibold tracking-[-0.035em] text-balance sm:text-5xl">{HEADLINE}</h1>
            <p className="mt-5 max-w-md text-base leading-relaxed text-pretty text-zinc-600 dark:text-zinc-400">{SUBLINE}</p>

            <div className="mt-9 w-full max-w-md rounded-2xl border border-zinc-200 bg-white text-left shadow-[0_12px_40px_-12px_rgb(0_0_0/0.22)] dark:border-white/10 dark:bg-[#0d0f16]">
              <label className="flex h-13 items-center gap-3 px-4">
                <svg aria-hidden viewBox="0 0 20 20" className="size-5 shrink-0 text-zinc-400" fill="none" stroke="currentColor" strokeWidth="1.8">
                  <circle cx="9" cy="9" r="6" />
                  <path d="m13.5 13.5 3.5 3.5" strokeLinecap="round" />
                </svg>
                <span className="sr-only">Search this site</span>
                <input
                  ref={inputRef}
                  value={query}
                  onChange={(event) => setQuery(event.target.value)}
                  placeholder={PLACEHOLDER}
                  aria-controls={listId}
                  autoComplete="off"
                  className="h-full min-w-0 flex-1 bg-transparent text-base text-zinc-950 placeholder:text-zinc-400 focus:outline-none dark:text-white dark:placeholder:text-zinc-500"
                />
                {trimmed ? (
                  <span className="shrink-0 text-xs font-medium tabular-nums text-[var(--accent)] dark:text-[var(--accent-dark)]">
                    {matches.length} {matches.length === 1 ? "page" : "pages"}
                  </span>
                ) : null}
              </label>
              {/* Grows under the box, pushing nothing above it. */}
              <ul id={listId} aria-label="Matching pages" className={trimmed ? "border-t border-zinc-100 p-1.5 dark:border-white/5" : "hidden"}>
                {matches.slice(0, LIMIT).map(({ page }) => (
                  <li key={page.href}>
                    <a
                      href={page.href}
                      className={`flex items-center justify-between gap-4 rounded-lg px-3 py-2.5 text-sm transition-colors duration-150 hover:bg-zinc-50 dark:hover:bg-white/5 ${ring}`}
                    >
                      <span className="font-medium text-zinc-900 dark:text-zinc-100">{page.label}</span>
                      <span className="truncate font-mono text-xs text-zinc-500">{page.href}</span>
                    </a>
                  </li>
                ))}
                {trimmed && !matches.length ? (
                  <li className="px-3 py-2.5 text-sm text-zinc-500">Nothing by that name. Try a shorter word.</li>
                ) : null}
              </ul>
            </div>

            <div className="mt-8 flex flex-wrap items-center justify-center gap-3">
              <a
                href={HOME.href}
                className={`rounded-full bg-zinc-950 px-5 py-2.5 text-sm font-medium text-white transition-colors duration-150 hover:bg-zinc-800 dark:bg-white dark:text-zinc-950 dark:hover:bg-zinc-200 ${ring}`}
              >
                {HOME.label}
              </a>
              <a
                href={CONTACT.href}
                className={`rounded-full border border-zinc-200 bg-white px-5 py-2.5 text-sm font-medium text-zinc-900 transition-colors duration-150 hover:border-zinc-300 hover:bg-zinc-50 dark:border-white/15 dark:bg-[#07080c] dark:text-white dark:hover:bg-white/5 ${ring}`}
              >
                {CONTACT.label}
              </a>
            </div>
          </div>
        </div>
      </Relief>
    </section>
  );
}
```
