# Not Found Terminal

> A page-not-found screen drawn as a terminal that answers a typed page name with a link.

```tsx
'use client';

import { NotFoundTerminal } from '@brand-studio/ui';

const links = [
  { href: '/docs', title: 'every guide' },
  { href: '/docs/api', title: 'API reference' },
  { href: '/changelog', title: 'what moved and when' },
];

// The links point at pages of a made-up docs site, so the demo keeps clicks on this page.
export default function NotFoundTerminalDemo() {
  return (
    <div onClickCapture={event => { if ((event.target as HTMLElement).closest('a')) event.preventDefault(); }} style={{ width: '100%', display: 'grid', justifyItems: 'center' }}>
      <NotFoundTerminal
        as="h2"
        name="roastery docs"
        path="/docs/api/webhoks"
        links={links}
        pages={['/docs/api/webhooks', '/docs/api/orders', '/docs/getting-started']}
        search="/search"
      />
    </div>
  );
}
```

## Installation

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, NotFoundTerminal } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { NotFoundTerminal } from '@brand-studio/ui';
```

```tsx
<NotFoundTerminal
  name="roastery docs"
  links={[{ href: '/docs', title: 'every guide' }, { href: '/changelog', title: 'what moved and when' }]}
  pages={sitemapPaths}
  search="/search"
/>
```

It prints the missing address, the closest of `links` and `pages` when the address looks like a typo, and `links` as places to try. A typed page name gets a link to the matching page. With no match, it links to `search` with the typed words.

## Accessibility

- The heading names the error in words, and every place to go is a real link.
- New answers are added to a log region, so screen readers hear each one once.
- The prompt has a label for screen readers; the dollar sign is decoration.

## API Reference

| Prop | Type | Default |
|---|---|---|
| `path?` | `string` | – |
| `links?` | `NotFoundLink[]` | – |
| `pages?` | `string[]` | – |
| `name?` | `string` | `'site'` |
| `title?` | `string` | `'error: page not found'` |
| `description?` | `string` | `'No page lives at this address.'` |
| `search?` | `string` | – |
| `inputLabel?` | `string` | `'Type a page name'` |
| `as?` | `React.ElementType` | – |
| `className?` | `string` | `''` |

Source: https://brandstudio.js.org/docs/components/not-found-terminal/
