# Not Found

Blok halaman 404 dan error siap pakai dengan enam tata letak: minimal, terbagi, pencarian dengan tautan tersaring, glitch, berilustrasi, dan terminal.

- Kategori: Section
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/not-found.json
- CLI: `npx markasui@latest add not-found`

## Kapan dipakai

Isi halaman 404, 403, 500, atau pemeliharaan, atau rute kosong di dalam aplikasi.

- Pakai satu blok not-found per halaman, blok ini merender h1
- Isi kode status asli dan judul yang jelas untuk error selain 404
- Beri variant search empat sampai delapan tautan populer
- Jaga deskripsi satu atau dua kalimat pendek

## Kode

### Blade

Simpan di `resources/views/components/markas/not-found.blade.php`. Dependensi: alpinejs.

```blade
@props([
    'variant' => 'minimal',
    'code' => '404',
    'title' => 'Page not found',
    'description' => 'The page you are looking for does not exist or has been moved.',
    'homeHref' => '/',
    'links' => [],
    'path' => '/page',
    'homeLabel' => 'Back to home',
    'backLabel' => 'Go back',
    'searchLabel' => 'Search pages',
    'emptyLabel' => 'No pages match your search',
])

@php
    $root = '@container grid w-full text-ink **:focus-visible:outline-2 **:focus-visible:outline-offset-2 **:focus-visible:outline-primary motion-reduce:**:animate-none motion-reduce:**:transition-none';
    $centered = 'mx-auto max-w-lg justify-items-center text-center';
    $layouts = [
        'minimal' => $centered,
        'split' => 'items-center gap-8 @xl:grid-cols-2',
        'search' => $centered,
        'glitch' => $centered,
        'illustrated' => $centered,
        'terminal' => 'mx-auto max-w-xl gap-6',
    ];
    $big = 'mb-2 text-8xl leading-none font-semibold tracking-tighter';
    $eyebrow = 'rounded-full border border-line px-2.5 py-0.5 text-xs font-medium text-muted';
    $codes = [
        'minimal' => $big,
        'glitch' => $big.' relative before:absolute before:inset-0 before:animate-[markas-glitch_2s_steps(1)_infinite] before:text-danger before:content-[attr(data-text)] after:absolute after:inset-0 after:animate-[markas-glitch_1.5s_steps(1)_infinite_reverse] after:text-success after:content-[attr(data-text)] motion-reduce:before:hidden motion-reduce:after:hidden',
        'illustrated' => $big.' relative grid *:col-start-1 *:row-start-1',
        'split' => $eyebrow,
        'search' => $eyebrow,
    ];
    $content = 'grid w-full gap-4 [justify-items:inherit]';
    $shadow = 'translate-2.5 text-primary/15';
    $outline = 'text-transparent [-webkit-text-stroke:2px_var(--color-ink)]';
    $compass = 'absolute -top-4 -right-10 size-12 rotate-12 rounded-full bg-canvas p-1 text-muted';
    $art = 'order-last mx-auto w-full max-w-xs';
    $artSoft = 'fill-primary-soft';
    $artStroke = 'fill-surface stroke-line';
    $artInk = 'fill-subtle stroke-ink';
    $titleClass = 'text-3xl font-semibold tracking-tight text-balance';
    $descriptionClass = 'max-w-prose text-pretty text-muted';
    $terminal = 'rounded-xl border border-line bg-surface p-4 text-left font-mono text-sm';
    $prompt = 'text-muted';
    $terminalTitle = 'text-danger';
    $cursor = 'inline-block h-4 w-2 animate-pulse bg-ink align-middle';
    $searchWrap = 'relative w-full text-sm';
    $searchIcon = 'absolute top-3 left-3 size-4 text-muted';
    $searchInput = 'h-10 w-full rounded-lg border border-line bg-surface pr-3 pl-9 placeholder:text-faint';
    $list = 'mt-3 divide-y divide-line rounded-xl border border-line bg-surface text-left';
    $listLink = 'flex justify-between rounded-xl px-4 py-3 font-medium hover:bg-subtle';
    $arrow = 'size-4 text-muted';
    $empty = 'text-muted not-empty:mt-3';
    $actions = 'flex flex-wrap gap-3';
    $button = 'inline-flex h-10 items-center gap-2 rounded-lg px-4 text-sm font-medium transition-colors duration-150 ease-out';
    $primary = 'bg-primary text-on-primary hover:bg-primary-strong';
    $secondary = 'border border-line bg-surface hover:bg-subtle';
    $backIcon = 'size-4';
    $keyframes = '@keyframes markas-glitch{0%{clip-path:inset(20% 0 55% 0);translate:-3px 1px}33%{clip-path:inset(60% 0 10% 0);translate:3px -1px}66%{clip-path:inset(35% 0 40% 0);translate:-2px 2px}}';
    $svg = 'viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"';

    // Href berskema selain http, https, mailto, dan tel (misalnya javascript:) diganti "#". Spasi dan karakter kontrol diabaikan seperti di browser.
    $safeHref = fn (?string $href): string => preg_match('/^(?!https?:|mailto:|tel:)[a-z][\w+.\-]*:/i', preg_replace('/[\x00-\x20]/', '', (string) $href)) === 1 ? '#' : (string) ($href ?? '#');
    $variant = array_key_exists($variant, $layouts) ? $variant : 'minimal';
    $links = array_values(array_map(fn ($link) => ['label' => (string) $link['label'], 'href' => $safeHref($link['href'] ?? '#')], $links));
    // Same id on every render, so Livewire's morph (which matches elements by id) keeps the element. Pass `id` to set it.
    $idKey = 'markas-not-found|'.(isset($this) && $this instanceof \Livewire\Component ? $this->getId() : '').'|'.($attributes->get('wire:key') ?? $attributes->whereStartsWith('wire:model')->first() ?? $attributes->get('name')).'|';
    for ($idIndex = 0; $__env->hasRenderedOnce($idKey.$idIndex); $idIndex++);
    $__env->markAsRenderedOnce($idKey.$idIndex);
    $titleId = ($attributes->get('id') ?? 'markas-not-found-'.hash('xxh32', $idKey.$idIndex)).'-title';
    $home = $safeHref($homeHref);
@endphp

<section
    x-data="{
        query: '',
        get needle() { return this.query.trim().toLowerCase() },
        matches(label) { return label.toLowerCase().includes(this.needle) },
        get count() { return @js($links).filter((link) => this.matches(link.label)).length },
        {{-- Kembali ke halaman sebelumnya; tanpa riwayat, link berjalan biasa ke homeHref. --}}
        back(event) {
            if (history.length < 2) return;
            event.preventDefault();
            history.back();
        },
    }"
    aria-labelledby="{{ $titleId }}"
    {{ $attributes->class([$root, $layouts[$variant]]) }}
>
    @if ($variant === 'split')
        <svg viewBox="0 0 240 200" class="{{ $art }}" aria-hidden="true"><circle cx="150" cy="92" r="64" class="{{ $artSoft }}" /><rect x="34" y="48" width="92" height="92" rx="14" stroke-width="2" class="{{ $artStroke }}" /><path d="M60 176 108 96l48 80z" stroke-width="2" class="{{ $artInk }}" /></svg>
    @endif
    @if ($variant === 'terminal')
        <div class="{{ $terminal }}">
            <p><span class="{{ $prompt }}">$ </span>cd {{ $path }}</p>
            <h1 id="{{ $titleId }}" class="{{ $terminalTitle }}">{{ $code }}: {{ $title }}</h1>
            <p aria-hidden="true"><span class="{{ $prompt }}">$ </span><span class="{{ $cursor }}"></span></p>
        </div>
    @endif
    <div class="{{ $content }}">
        @isset($codes[$variant])
            <p aria-hidden="true" data-text="{{ $code }}" class="{{ $codes[$variant] }}">@if ($variant === 'glitch')<style>{!! $keyframes !!}</style>@endif @if ($variant === 'illustrated')<span class="{{ $shadow }}">{{ $code }}</span><span class="{{ $outline }}">{{ $code }}</span><svg class="{{ $compass }}" {!! $svg !!}><path d="M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zm4.2-14.2-2.1 6.3-6.3 2.1 2.1-6.3z" /></svg>@else{{ $code }}@endif</p>
        @endisset
        @if ($variant !== 'terminal')
            <h1 id="{{ $titleId }}" class="{{ $titleClass }}">{{ $title }}</h1>
        @endif
        <p class="{{ $descriptionClass }}">{{ $description }}</p>
        @if ($variant === 'search')
            <div class="{{ $searchWrap }}">
                <svg class="{{ $searchIcon }}" {!! $svg !!}><path d="m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z" /></svg>
                <input type="search" x-model="query" aria-label="{{ $searchLabel }}" placeholder="{{ $searchLabel }}" class="{{ $searchInput }}" />
                @if (count($links))
                    <ul x-show="count" class="{{ $list }}">
                        @foreach ($links as $link)
                            <li x-show="matches(@js($link['label']))"><a href="{{ $link['href'] }}" class="{{ $listLink }}">{{ $link['label'] }}<svg class="{{ $arrow }}" {!! $svg !!}><path d="M5 12h14m-6-6 6 6-6 6" /></svg></a></li>
                        @endforeach
                    </ul>
                @endif
                <p role="status" class="{{ $empty }}" x-text="needle && !count ? @js($emptyLabel) : ''"></p>
            </div>
        @endif
        <div class="{{ $actions }}">
            <a href="{{ $home }}" class="{{ $button }} {{ $primary }}">{{ $homeLabel }}</a>
            <a href="{{ $home }}" @click="back($event)" class="{{ $button }} {{ $secondary }}"><svg class="{{ $backIcon }}" {!! $svg !!}><path d="M19 12H5m6 6-6-6 6-6" /></svg>{{ $backLabel }}</a>
        </div>
    </div>
</section>
```

```blade
<x-markas.not-found
    title="Halaman tidak ditemukan"
    description="Halaman yang kamu cari tidak ada atau sudah dipindahkan."
    home-label="Kembali ke beranda"
    back-label="Kembali"
/>

<x-markas.not-found
    variant="search"
    search-label="Cari halaman"
    empty-label="Tidak ada halaman yang cocok"
    :links="[
        ['label' => 'Dokumentasi', 'href' => '/docs'],
        ['label' => 'Harga', 'href' => '/harga'],
    ]"
/>
```

Butuh Alpine.js untuk Kembali dan penyaring pencarian.

### React

Simpan di `src/components/markas/NotFound.tsx`. Tanpa dependensi tambahan.

```tsx
"use client";

import {
  useId,
  useState,
  type ComponentProps,
  type MouseEvent,
  type ReactNode,
} from "react";

const root =
  "@container grid w-full text-ink **:focus-visible:outline-2 **:focus-visible:outline-offset-2 **:focus-visible:outline-primary motion-reduce:**:animate-none motion-reduce:**:transition-none";
const centered = "mx-auto max-w-lg justify-items-center text-center";
const layouts = {
  minimal: centered,
  split: "items-center gap-8 @xl:grid-cols-2",
  search: centered,
  glitch: centered,
  illustrated: centered,
  terminal: "mx-auto max-w-xl gap-6",
};
const big = "mb-2 text-8xl leading-none font-semibold tracking-tighter";
const eyebrow =
  "rounded-full border border-line px-2.5 py-0.5 text-xs font-medium text-muted";
const codes: Record<string, string> = {
  minimal: big,
  glitch: `${big} relative before:absolute before:inset-0 before:animate-[markas-glitch_2s_steps(1)_infinite] before:text-danger before:content-[attr(data-text)] after:absolute after:inset-0 after:animate-[markas-glitch_1.5s_steps(1)_infinite_reverse] after:text-success after:content-[attr(data-text)] motion-reduce:before:hidden motion-reduce:after:hidden`,
  illustrated: `${big} relative grid *:col-start-1 *:row-start-1`,
  split: eyebrow,
  search: eyebrow,
};
const content = "grid w-full gap-4 [justify-items:inherit]";
const shadow = "translate-2.5 text-primary/15";
const outline = "text-transparent [-webkit-text-stroke:2px_var(--color-ink)]";
const compass =
  "absolute -top-4 -right-10 size-12 rotate-12 rounded-full bg-canvas p-1 text-muted";
const art = "order-last mx-auto w-full max-w-xs";
const artSoft = "fill-primary-soft";
const artStroke = "fill-surface stroke-line";
const artInk = "fill-subtle stroke-ink";
const titleClass = "text-3xl font-semibold tracking-tight text-balance";
const descriptionClass = "max-w-prose text-pretty text-muted";
const terminal =
  "rounded-xl border border-line bg-surface p-4 text-left font-mono text-sm";
const prompt = "text-muted";
const terminalTitle = "text-danger";
const cursor = "inline-block h-4 w-2 animate-pulse bg-ink align-middle";
const searchWrap = "relative w-full text-sm";
const searchIcon = "absolute top-3 left-3 size-4 text-muted";
const searchInput =
  "h-10 w-full rounded-lg border border-line bg-surface pr-3 pl-9 placeholder:text-faint";
const list =
  "mt-3 divide-y divide-line rounded-xl border border-line bg-surface text-left";
const listLink =
  "flex justify-between rounded-xl px-4 py-3 font-medium hover:bg-subtle";
const arrow = "size-4 text-muted";
const empty = "text-muted not-empty:mt-3";
const actions = "flex flex-wrap gap-3";
const button =
  "inline-flex h-10 items-center gap-2 rounded-lg px-4 text-sm font-medium transition-colors duration-150 ease-out";
const primary = "bg-primary text-on-primary hover:bg-primary-strong";
const secondary = "border border-line bg-surface hover:bg-subtle";
const backIcon = "size-4";
const keyframes =
  "@keyframes markas-glitch{0%{clip-path:inset(20% 0 55% 0);translate:-3px 1px}33%{clip-path:inset(60% 0 10% 0);translate:3px -1px}66%{clip-path:inset(35% 0 40% 0);translate:-2px 2px}}";

const cx = (...c: (string | false | undefined)[]) =>
  c.filter(Boolean).join(" ");

/** Href berskema selain http, https, mailto, dan tel (misalnya javascript:) diganti "#". Spasi dan karakter kontrol diabaikan seperti di browser. */
const safeHref = (href = "#") =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

/** Kembali ke halaman sebelumnya; tanpa riwayat, link berjalan biasa ke homeHref. */
const goBack = (event: MouseEvent) => {
  if (history.length < 2) return;
  event.preventDefault();
  history.back();
};

const icon = (path: string, className: string) => (
  <svg
    className={className}
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth="1.5"
    strokeLinecap="round"
    strokeLinejoin="round"
    aria-hidden="true"
  >
    <path d={path} />
  </svg>
);

export type NotFoundLink = { label: string; href: string };

export type NotFoundProps = Omit<ComponentProps<"section">, "title"> & {
  /** minimal, split, search, glitch, illustrated, atau terminal. */
  variant?: keyof typeof layouts;
  /** Kode status, misalnya 404, 403, atau 500. */
  code?: string;
  title?: ReactNode;
  description?: ReactNode;
  homeHref?: string;
  /** Tautan populer yang bisa disaring di variant search. */
  links?: NotFoundLink[];
  /** Path yang tampil di variant terminal. */
  path?: string;
  homeLabel?: string;
  backLabel?: string;
  searchLabel?: string;
  emptyLabel?: string;
};

export function NotFound({
  variant = "minimal",
  code = "404",
  title = "Page not found",
  description = "The page you are looking for does not exist or has been moved.",
  homeHref = "/",
  links = [],
  path = "/page",
  homeLabel = "Back to home",
  backLabel = "Go back",
  searchLabel = "Search pages",
  emptyLabel = "No pages match your search",
  id,
  className,
  ...props
}: NotFoundProps) {
  const generatedId = useId();
  const titleId = `${id ?? generatedId}-title`;
  const [query, setQuery] = useState("");
  const needle = query.trim().toLowerCase();
  const visible = links.filter((link) =>
    link.label.toLowerCase().includes(needle),
  );
  const isTerminal = variant === "terminal";
  const heading = (
    <h1 id={titleId} className={isTerminal ? terminalTitle : titleClass}>
      {isTerminal && `${code}: `}
      {title}
    </h1>
  );

  return (
    <section
      id={id}
      aria-labelledby={titleId}
      className={cx(root, layouts[variant], className)}
      {...props}
    >
      {variant === "split" && (
        <svg viewBox="0 0 240 200" className={art} aria-hidden="true">
          <circle cx="150" cy="92" r="64" className={artSoft} />
          <rect
            x="34"
            y="48"
            width="92"
            height="92"
            rx="14"
            strokeWidth="2"
            className={artStroke}
          />
          <path d="M60 176 108 96l48 80z" strokeWidth="2" className={artInk} />
        </svg>
      )}
      {isTerminal && (
        <div className={terminal}>
          <p>
            <span className={prompt}>$ </span>cd {path}
          </p>
          {heading}
          <p aria-hidden="true">
            <span className={prompt}>$ </span>
            <span className={cursor} />
          </p>
        </div>
      )}
      <div className={content}>
        {codes[variant] && (
          <p aria-hidden="true" data-text={code} className={codes[variant]}>
            {variant === "glitch" && <style>{keyframes}</style>}
            {variant === "illustrated" ? (
              <>
                <span className={shadow}>{code}</span>
                <span className={outline}>{code}</span>
                {icon(
                  "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zm4.2-14.2-2.1 6.3-6.3 2.1 2.1-6.3z",
                  compass,
                )}
              </>
            ) : (
              code
            )}
          </p>
        )}
        {!isTerminal && heading}
        <p className={descriptionClass}>{description}</p>
        {variant === "search" && (
          <div className={searchWrap}>
            {icon(
              "m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z",
              searchIcon,
            )}
            <input
              type="search"
              aria-label={searchLabel}
              placeholder={searchLabel}
              value={query}
              onChange={(event) => setQuery(event.target.value)}
              className={searchInput}
            />
            {visible.length > 0 && (
              <ul className={list}>
                {visible.map((link) => (
                  <li key={link.href}>
                    <a href={safeHref(link.href)} className={listLink}>
                      {link.label}
                      {icon("M5 12h14m-6-6 6 6-6 6", arrow)}
                    </a>
                  </li>
                ))}
              </ul>
            )}
            <p role="status" className={empty}>
              {needle && !visible.length ? emptyLabel : ""}
            </p>
          </div>
        )}
        <div className={actions}>
          <a href={safeHref(homeHref)} className={cx(button, primary)}>
            {homeLabel}
          </a>
          <a
            href={safeHref(homeHref)}
            onClick={goBack}
            className={cx(button, secondary)}
          >
            {icon("M19 12H5m6 6-6-6 6-6", backIcon)}
            {backLabel}
          </a>
        </div>
      </div>
    </section>
  );
}
```

```tsx
import { NotFound } from "@/components/markas/NotFound";

<NotFound
  title="Halaman tidak ditemukan"
  description="Halaman yang kamu cari tidak ada atau sudah dipindahkan."
  homeLabel="Kembali ke beranda"
  backLabel="Kembali"
/>
<NotFound
  variant="search"
  searchLabel="Cari halaman"
  emptyLabel="Tidak ada halaman yang cocok"
  links={[
    { label: "Dokumentasi", href: "/docs" },
    { label: "Harga", href: "/harga" },
  ]}
/>
```

### Vue

Simpan di `src/components/markas/NotFound.vue`. Tanpa dependensi tambahan.

```vue
<script setup lang="ts">
import { computed, ref, useId } from "vue";

export type NotFoundLink = { label: string; href: string };

const props = withDefaults(
  defineProps<{
    /** minimal, split, search, glitch, illustrated, atau terminal. */
    variant?:
      "minimal" | "split" | "search" | "glitch" | "illustrated" | "terminal";
    /** Kode status, misalnya 404, 403, atau 500. */
    code?: string;
    title?: string;
    description?: string;
    homeHref?: string;
    /** Tautan populer yang bisa disaring di variant search. */
    links?: NotFoundLink[];
    /** Path yang tampil di variant terminal. */
    path?: string;
    id?: string;
    homeLabel?: string;
    backLabel?: string;
    searchLabel?: string;
    emptyLabel?: string;
  }>(),
  {
    variant: "minimal",
    code: "404",
    title: "Page not found",
    description:
      "The page you are looking for does not exist or has been moved.",
    homeHref: "/",
    links: () => [],
    path: "/page",
    id: undefined,
    homeLabel: "Back to home",
    backLabel: "Go back",
    searchLabel: "Search pages",
    emptyLabel: "No pages match your search",
  },
);

const root =
  "@container grid w-full text-ink **:focus-visible:outline-2 **:focus-visible:outline-offset-2 **:focus-visible:outline-primary motion-reduce:**:animate-none motion-reduce:**:transition-none";
const centered = "mx-auto max-w-lg justify-items-center text-center";
const layouts = {
  minimal: centered,
  split: "items-center gap-8 @xl:grid-cols-2",
  search: centered,
  glitch: centered,
  illustrated: centered,
  terminal: "mx-auto max-w-xl gap-6",
};
const big = "mb-2 text-8xl leading-none font-semibold tracking-tighter";
const eyebrow =
  "rounded-full border border-line px-2.5 py-0.5 text-xs font-medium text-muted";
const codes: Record<string, string> = {
  minimal: big,
  glitch: `${big} relative before:absolute before:inset-0 before:animate-[markas-glitch_2s_steps(1)_infinite] before:text-danger before:content-[attr(data-text)] after:absolute after:inset-0 after:animate-[markas-glitch_1.5s_steps(1)_infinite_reverse] after:text-success after:content-[attr(data-text)] motion-reduce:before:hidden motion-reduce:after:hidden`,
  illustrated: `${big} relative grid *:col-start-1 *:row-start-1`,
  split: eyebrow,
  search: eyebrow,
};
const content = "grid w-full gap-4 [justify-items:inherit]";
const shadow = "translate-2.5 text-primary/15";
const outline = "text-transparent [-webkit-text-stroke:2px_var(--color-ink)]";
const compass =
  "absolute -top-4 -right-10 size-12 rotate-12 rounded-full bg-canvas p-1 text-muted";
const art = "order-last mx-auto w-full max-w-xs";
const artSoft = "fill-primary-soft";
const artStroke = "fill-surface stroke-line";
const artInk = "fill-subtle stroke-ink";
const titleClass = "text-3xl font-semibold tracking-tight text-balance";
const descriptionClass = "max-w-prose text-pretty text-muted";
const terminal =
  "rounded-xl border border-line bg-surface p-4 text-left font-mono text-sm";
const prompt = "text-muted";
const terminalTitle = "text-danger";
const cursor = "inline-block h-4 w-2 animate-pulse bg-ink align-middle";
const searchWrap = "relative w-full text-sm";
const searchIcon = "absolute top-3 left-3 size-4 text-muted";
const searchInput =
  "h-10 w-full rounded-lg border border-line bg-surface pr-3 pl-9 placeholder:text-faint";
const list =
  "mt-3 divide-y divide-line rounded-xl border border-line bg-surface text-left";
const listLink =
  "flex justify-between rounded-xl px-4 py-3 font-medium hover:bg-subtle";
const arrow = "size-4 text-muted";
const empty = "text-muted not-empty:mt-3";
const actions = "flex flex-wrap gap-3";
const button =
  "inline-flex h-10 items-center gap-2 rounded-lg px-4 text-sm font-medium transition-colors duration-150 ease-out";
const primary = "bg-primary text-on-primary hover:bg-primary-strong";
const secondary = "border border-line bg-surface hover:bg-subtle";
const backIcon = "size-4";
const keyframes =
  "@keyframes markas-glitch{0%{clip-path:inset(20% 0 55% 0);translate:-3px 1px}33%{clip-path:inset(60% 0 10% 0);translate:3px -1px}66%{clip-path:inset(35% 0 40% 0);translate:-2px 2px}}";

const svgAttrs = {
  viewBox: "0 0 24 24",
  fill: "none",
  stroke: "currentColor",
  "stroke-width": "1.5",
  "stroke-linecap": "round",
  "stroke-linejoin": "round",
  "aria-hidden": "true",
} as const;

/** Href berskema selain http, https, mailto, dan tel (misalnya javascript:) diganti "#". Spasi dan karakter kontrol diabaikan seperti di browser. */
const safeHref = (href = "#") =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

/** Kembali ke halaman sebelumnya; tanpa riwayat, link berjalan biasa ke homeHref. */
const goBack = (event: MouseEvent) => {
  if (history.length < 2) return;
  event.preventDefault();
  history.back();
};

const generatedId = useId();
const titleId = computed(() => `${props.id ?? generatedId}-title`);
const query = ref("");
const needle = computed(() => query.value.trim().toLowerCase());
const visible = computed(() =>
  props.links.filter((link) => link.label.toLowerCase().includes(needle.value)),
);
</script>

<template>
  <section
    :id="props.id"
    :aria-labelledby="titleId"
    :class="[root, layouts[props.variant]]"
  >
    <svg
      v-if="props.variant === 'split'"
      viewBox="0 0 240 200"
      :class="art"
      aria-hidden="true"
    >
      <circle cx="150" cy="92" r="64" :class="artSoft" />
      <rect
        x="34"
        y="48"
        width="92"
        height="92"
        rx="14"
        stroke-width="2"
        :class="artStroke"
      />
      <path d="M60 176 108 96l48 80z" stroke-width="2" :class="artInk" />
    </svg>
    <div v-if="props.variant === 'terminal'" :class="terminal">
      <p><span :class="prompt">$ </span>cd {{ props.path }}</p>
      <h1 :id="titleId" :class="terminalTitle">
        {{ `${props.code}: ` }}{{ props.title }}
      </h1>
      <p aria-hidden="true">
        <span :class="prompt">$ </span><span :class="cursor" />
      </p>
    </div>
    <div :class="content">
      <p
        v-if="codes[props.variant]"
        aria-hidden="true"
        :data-text="props.code"
        :class="codes[props.variant]"
      >
        <component :is="'style'" v-if="props.variant === 'glitch'">{{
          keyframes
        }}</component>
        <template v-if="props.variant === 'illustrated'"
          ><span :class="shadow">{{ props.code }}</span
          ><span :class="outline">{{ props.code }}</span
          ><svg :class="compass" v-bind="svgAttrs">
            <path
              d="M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zm4.2-14.2-2.1 6.3-6.3 2.1 2.1-6.3z"
            /></svg
        ></template>
        <template v-else>{{ props.code }}</template>
      </p>
      <h1 v-if="props.variant !== 'terminal'" :id="titleId" :class="titleClass">
        {{ props.title }}
      </h1>
      <p :class="descriptionClass">{{ props.description }}</p>
      <div v-if="props.variant === 'search'" :class="searchWrap">
        <svg :class="searchIcon" v-bind="svgAttrs">
          <path d="m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z" />
        </svg>
        <input
          v-model="query"
          type="search"
          :aria-label="props.searchLabel"
          :placeholder="props.searchLabel"
          :class="searchInput"
        />
        <ul v-if="visible.length" :class="list">
          <li v-for="link in visible" :key="link.href">
            <a :href="safeHref(link.href)" :class="listLink"
              >{{ link.label
              }}<svg :class="arrow" v-bind="svgAttrs">
                <path d="M5 12h14m-6-6 6 6-6 6" /></svg
            ></a>
          </li>
        </ul>
        <p role="status" :class="empty">
          {{ needle && !visible.length ? props.emptyLabel : "" }}
        </p>
      </div>
      <div :class="actions">
        <a :href="safeHref(props.homeHref)" :class="[button, primary]">{{
          props.homeLabel
        }}</a>
        <a
          :href="safeHref(props.homeHref)"
          :class="[button, secondary]"
          @click="goBack"
          ><svg :class="backIcon" v-bind="svgAttrs">
            <path d="M19 12H5m6 6-6-6 6-6" /></svg
          >{{ props.backLabel }}</a
        >
      </div>
    </div>
  </section>
</template>
```

```vue
<script setup lang="ts">
import NotFound from "@/components/markas/NotFound.vue";

const links = [
  { label: "Dokumentasi", href: "/docs" },
  { label: "Harga", href: "/harga" },
];
</script>

<template>
  <NotFound
    title="Halaman tidak ditemukan"
    description="Halaman yang kamu cari tidak ada atau sudah dipindahkan."
    home-label="Kembali ke beranda"
    back-label="Kembali"
  />
  <NotFound
    variant="search"
    search-label="Cari halaman"
    empty-label="Tidak ada halaman yang cocok"
    :links="links"
  />
</template>
```

### Svelte

Simpan di `src/lib/components/markas/NotFound.svelte`. Tanpa dependensi tambahan.

```svelte
<script module lang="ts">
  export type NotFoundLink = { label: string; href: string };
  export type NotFoundVariant =
    "minimal" | "split" | "search" | "glitch" | "illustrated" | "terminal";
</script>

<script lang="ts">
  import type { HTMLAttributes } from "svelte/elements";

  const root =
    "@container grid w-full text-ink **:focus-visible:outline-2 **:focus-visible:outline-offset-2 **:focus-visible:outline-primary motion-reduce:**:animate-none motion-reduce:**:transition-none";
  const centered = "mx-auto max-w-lg justify-items-center text-center";
  const layouts = {
    minimal: centered,
    split: "items-center gap-8 @xl:grid-cols-2",
    search: centered,
    glitch: centered,
    illustrated: centered,
    terminal: "mx-auto max-w-xl gap-6",
  };
  const big = "mb-2 text-8xl leading-none font-semibold tracking-tighter";
  const eyebrow =
    "rounded-full border border-line px-2.5 py-0.5 text-xs font-medium text-muted";
  const codes: Record<string, string> = {
    minimal: big,
    glitch: `${big} relative before:absolute before:inset-0 before:animate-[markas-glitch_2s_steps(1)_infinite] before:text-danger before:content-[attr(data-text)] after:absolute after:inset-0 after:animate-[markas-glitch_1.5s_steps(1)_infinite_reverse] after:text-success after:content-[attr(data-text)] motion-reduce:before:hidden motion-reduce:after:hidden`,
    illustrated: `${big} relative grid *:col-start-1 *:row-start-1`,
    split: eyebrow,
    search: eyebrow,
  };
  const content = "grid w-full gap-4 [justify-items:inherit]";
  const shadow = "translate-2.5 text-primary/15";
  const outline = "text-transparent [-webkit-text-stroke:2px_var(--color-ink)]";
  const compass =
    "absolute -top-4 -right-10 size-12 rotate-12 rounded-full bg-canvas p-1 text-muted";
  const art = "order-last mx-auto w-full max-w-xs";
  const artSoft = "fill-primary-soft";
  const artStroke = "fill-surface stroke-line";
  const artInk = "fill-subtle stroke-ink";
  const titleClass = "text-3xl font-semibold tracking-tight text-balance";
  const descriptionClass = "max-w-prose text-pretty text-muted";
  const terminal =
    "rounded-xl border border-line bg-surface p-4 text-left font-mono text-sm";
  const prompt = "text-muted";
  const terminalTitle = "text-danger";
  const cursor = "inline-block h-4 w-2 animate-pulse bg-ink align-middle";
  const searchWrap = "relative w-full text-sm";
  const searchIcon = "absolute top-3 left-3 size-4 text-muted";
  const searchInput =
    "h-10 w-full rounded-lg border border-line bg-surface pr-3 pl-9 placeholder:text-faint";
  const list =
    "mt-3 divide-y divide-line rounded-xl border border-line bg-surface text-left";
  const listLink =
    "flex justify-between rounded-xl px-4 py-3 font-medium hover:bg-subtle";
  const arrow = "size-4 text-muted";
  const empty = "text-muted not-empty:mt-3";
  const actions = "flex flex-wrap gap-3";
  const button =
    "inline-flex h-10 items-center gap-2 rounded-lg px-4 text-sm font-medium transition-colors duration-150 ease-out";
  const primary = "bg-primary text-on-primary hover:bg-primary-strong";
  const secondary = "border border-line bg-surface hover:bg-subtle";
  const backIcon = "size-4";
  const keyframes =
    "@keyframes markas-glitch{0%{clip-path:inset(20% 0 55% 0);translate:-3px 1px}33%{clip-path:inset(60% 0 10% 0);translate:3px -1px}66%{clip-path:inset(35% 0 40% 0);translate:-2px 2px}}";

  /** Hrefs with a scheme other than http, https, mailto, and tel (javascript: for one) become "#". Spaces and control characters are ignored, as browsers do. */
  const safeHref = (href = "#") =>
    /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
      ? "#"
      : href;

  /** Go back to the previous page; without history the link simply goes to homeHref. */
  const goBack = (event: MouseEvent) => {
    if (history.length < 2) return;
    event.preventDefault();
    history.back();
  };

  type Props = Omit<HTMLAttributes<HTMLElement>, "title"> & {
    /** minimal, split, search, glitch, illustrated, or terminal. */
    variant?: NotFoundVariant;
    /** Status code, for example 404, 403, or 500. */
    code?: string;
    title?: string;
    description?: string;
    homeHref?: string;
    /** Popular links that can be filtered in the search variant. */
    links?: NotFoundLink[];
    /** Path shown in the terminal variant. */
    path?: string;
    homeLabel?: string;
    backLabel?: string;
    searchLabel?: string;
    emptyLabel?: string;
  };

  let {
    variant = "minimal",
    code = "404",
    title = "Page not found",
    description = "The page you are looking for does not exist or has been moved.",
    homeHref = "/",
    links = [],
    path = "/page",
    homeLabel = "Back to home",
    backLabel = "Go back",
    searchLabel = "Search pages",
    emptyLabel = "No pages match your search",
    id,
    class: className,
    ...rest
  }: Props = $props();

  const generatedId = $props.id();
  const titleId = $derived(`${id ?? generatedId}-title`);
  let query = $state("");
  const needle = $derived(query.trim().toLowerCase());
  const visible = $derived(
    links.filter((link) => link.label.toLowerCase().includes(needle)),
  );
</script>

{#snippet icon(path: string, className: string)}
  <svg
    class={className}
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    stroke-width="1.5"
    stroke-linecap="round"
    stroke-linejoin="round"
    aria-hidden="true"
  >
    <path d={path} />
  </svg>
{/snippet}

<section
  {id}
  aria-labelledby={titleId}
  class={[root, layouts[variant], className]}
  {...rest}
>
  {#if variant === "split"}
    <svg viewBox="0 0 240 200" class={art} aria-hidden="true">
      <circle cx="150" cy="92" r="64" class={artSoft} />
      <rect
        x="34"
        y="48"
        width="92"
        height="92"
        rx="14"
        stroke-width="2"
        class={artStroke}
      />
      <path d="M60 176 108 96l48 80z" stroke-width="2" class={artInk} />
    </svg>
  {/if}
  {#if variant === "terminal"}
    <div class={terminal}>
      <p><span class={prompt}>$ </span>cd {path}</p>
      <h1 id={titleId} class={terminalTitle}>{`${code}: `}{title}</h1>
      <p aria-hidden="true">
        <span class={prompt}>$ </span><span class={cursor}></span>
      </p>
    </div>
  {/if}
  <div class={content}>
    {#if codes[variant]}
      <p aria-hidden="true" data-text={code} class={codes[variant]}>
        {#if variant === "glitch"}{@html `<style>${keyframes}</style>`}{/if}{#if variant === "illustrated"}<span
            class={shadow}>{code}</span
          ><span class={outline}>{code}</span>{@render icon(
            "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zm4.2-14.2-2.1 6.3-6.3 2.1 2.1-6.3z",
            compass,
          )}{:else}{code}{/if}
      </p>
    {/if}
    {#if variant !== "terminal"}
      <h1 id={titleId} class={titleClass}>{title}</h1>
    {/if}
    <p class={descriptionClass}>{description}</p>
    {#if variant === "search"}
      <div class={searchWrap}>
        {@render icon(
          "m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z",
          searchIcon,
        )}
        <input
          type="search"
          aria-label={searchLabel}
          placeholder={searchLabel}
          bind:value={query}
          class={searchInput}
        />
        {#if visible.length > 0}
          <ul class={list}>
            {#each visible as link (link.href)}
              <li>
                <a href={safeHref(link.href)} class={listLink}
                  >{link.label}{@render icon("M5 12h14m-6-6 6 6-6 6", arrow)}</a
                >
              </li>
            {/each}
          </ul>
        {/if}
        <p role="status" class={empty}>
          {needle && !visible.length ? emptyLabel : ""}
        </p>
      </div>
    {/if}
    <div class={actions}>
      <a href={safeHref(homeHref)} class={[button, primary]}>{homeLabel}</a>
      <a href={safeHref(homeHref)} onclick={goBack} class={[button, secondary]}
        >{@render icon("M19 12H5m6 6-6-6 6-6", backIcon)}{backLabel}</a
      >
    </div>
  </div>
</section>
```

```svelte
<script lang="ts">
  import NotFound from "$lib/components/markas/NotFound.svelte";
</script>

<NotFound />
<NotFound variant="search" {links} />
<NotFound variant="glitch" code="500" title="Something went wrong" />
```

### Astro

Simpan di `src/components/markas/NotFound.astro`. Tanpa dependensi tambahan.

```astro
---
import type { HTMLAttributes } from "astro/types";

const root =
  "@container grid w-full text-ink **:focus-visible:outline-2 **:focus-visible:outline-offset-2 **:focus-visible:outline-primary motion-reduce:**:animate-none motion-reduce:**:transition-none";
const centered = "mx-auto max-w-lg justify-items-center text-center";
const layouts = {
  minimal: centered,
  split: "items-center gap-8 @xl:grid-cols-2",
  search: centered,
  glitch: centered,
  illustrated: centered,
  terminal: "mx-auto max-w-xl gap-6",
};
const big = "mb-2 text-8xl leading-none font-semibold tracking-tighter";
const eyebrow =
  "rounded-full border border-line px-2.5 py-0.5 text-xs font-medium text-muted";
const codes: Record<string, string> = {
  minimal: big,
  glitch: `${big} relative before:absolute before:inset-0 before:animate-[markas-glitch_2s_steps(1)_infinite] before:text-danger before:content-[attr(data-text)] after:absolute after:inset-0 after:animate-[markas-glitch_1.5s_steps(1)_infinite_reverse] after:text-success after:content-[attr(data-text)] motion-reduce:before:hidden motion-reduce:after:hidden`,
  illustrated: `${big} relative grid *:col-start-1 *:row-start-1`,
  split: eyebrow,
  search: eyebrow,
};
const content = "grid w-full gap-4 [justify-items:inherit]";
const shadow = "translate-2.5 text-primary/15";
const outline = "text-transparent [-webkit-text-stroke:2px_var(--color-ink)]";
const compass =
  "absolute -top-4 -right-10 size-12 rotate-12 rounded-full bg-canvas p-1 text-muted";
const art = "order-last mx-auto w-full max-w-xs";
const artSoft = "fill-primary-soft";
const artStroke = "fill-surface stroke-line";
const artInk = "fill-subtle stroke-ink";
const titleClass = "text-3xl font-semibold tracking-tight text-balance";
const descriptionClass = "max-w-prose text-pretty text-muted";
const terminal =
  "rounded-xl border border-line bg-surface p-4 text-left font-mono text-sm";
const prompt = "text-muted";
const terminalTitle = "text-danger";
const cursor = "inline-block h-4 w-2 animate-pulse bg-ink align-middle";
const searchWrap = "relative w-full text-sm";
const searchIcon = "absolute top-3 left-3 size-4 text-muted";
const searchInput =
  "h-10 w-full rounded-lg border border-line bg-surface pr-3 pl-9 placeholder:text-faint";
const list =
  "mt-3 divide-y divide-line rounded-xl border border-line bg-surface text-left";
const listLink =
  "flex justify-between rounded-xl px-4 py-3 font-medium hover:bg-subtle";
const arrow = "size-4 text-muted";
const empty = "text-muted not-empty:mt-3";
const actions = "flex flex-wrap gap-3";
const button =
  "inline-flex h-10 items-center gap-2 rounded-lg px-4 text-sm font-medium transition-colors duration-150 ease-out";
const primary = "bg-primary text-on-primary hover:bg-primary-strong";
const secondary = "border border-line bg-surface hover:bg-subtle";
const backIcon = "size-4";
const keyframes =
  "@keyframes markas-glitch{0%{clip-path:inset(20% 0 55% 0);translate:-3px 1px}33%{clip-path:inset(60% 0 10% 0);translate:3px -1px}66%{clip-path:inset(35% 0 40% 0);translate:-2px 2px}}";

/** Hrefs with a scheme other than http, https, mailto, and tel (javascript: for one) become "#". Spaces and control characters are ignored, as browsers do. */
const safeHref = (href = "#") =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

export type NotFoundLink = { label: string; href: string };
export type NotFoundVariant = keyof typeof layouts;

type Props = Omit<HTMLAttributes<"section">, "title"> & {
  /** minimal, split, search, glitch, illustrated, or terminal. */
  variant?: NotFoundVariant;
  /** Status code, for example 404, 403, or 500. */
  code?: string;
  title?: string;
  description?: string;
  homeHref?: string;
  /** Popular links that can be filtered in the search variant. */
  links?: NotFoundLink[];
  /** Path shown in the terminal variant. */
  path?: string;
  homeLabel?: string;
  backLabel?: string;
  searchLabel?: string;
  emptyLabel?: string;
};

const {
  variant = "minimal",
  code = "404",
  title = "Page not found",
  description = "The page you are looking for does not exist or has been moved.",
  homeHref = "/",
  links = [],
  path = "/page",
  homeLabel = "Back to home",
  backLabel = "Go back",
  searchLabel = "Search pages",
  emptyLabel = "No pages match your search",
  id,
  class: className,
  ...rest
} = Astro.props;
const titleId = `${id ?? `markas-not-found-${crypto.randomUUID().slice(0, 8)}`}-title`;
const icon = (d: string) => ({ d });
const svg = {
  viewBox: "0 0 24 24",
  fill: "none",
  stroke: "currentColor",
  "stroke-width": "1.5",
  "stroke-linecap": "round",
  "stroke-linejoin": "round",
  "aria-hidden": "true",
} as const;
const paths = {
  compass: icon(
    "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zm4.2-14.2-2.1 6.3-6.3 2.1 2.1-6.3z",
  ),
  search: icon("m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z"),
  arrow: icon("M5 12h14m-6-6 6 6-6 6"),
  back: icon("M19 12H5m6 6-6-6 6-6"),
};
---

<section
  id={id}
  aria-labelledby={titleId}
  data-markas-not-found
  class:list={[root, layouts[variant], className]}
  {...rest}
>
  {
    variant === "split" && (
      <svg viewBox="0 0 240 200" class={art} aria-hidden="true">
        <circle cx="150" cy="92" r="64" class={artSoft} />
        <rect
          x="34"
          y="48"
          width="92"
          height="92"
          rx="14"
          stroke-width="2"
          class={artStroke}
        />
        <path d="M60 176 108 96l48 80z" stroke-width="2" class={artInk} />
      </svg>
    )
  }
  {
    variant === "terminal" && (
      <div class={terminal}>
        <p>
          <span class={prompt}>$ </span>cd {path}
        </p>
        <h1 id={titleId} class={terminalTitle}>
          {`${code}: `}
          {title}
        </h1>
        <p aria-hidden="true">
          <span class={prompt}>$ </span>
          <span class={cursor} />
        </p>
      </div>
    )
  }
  <div class={content}>
    {
      codes[variant] && (
        <p aria-hidden="true" data-text={code} class={codes[variant]}>
          {variant === "glitch" && <style is:inline set:html={keyframes} />}
          {variant === "illustrated" ? (
            <>
              <span class={shadow}>{code}</span>
              <span class={outline}>{code}</span>
              <svg class={compass} {...svg}>
                <path d={paths.compass.d} />
              </svg>
            </>
          ) : (
            code
          )}
        </p>
      )
    }
    {
      variant !== "terminal" && (
        <h1 id={titleId} class={titleClass}>
          {title}
        </h1>
      )
    }
    <p class={descriptionClass}>{description}</p>
    {
      variant === "search" && (
        <div class={searchWrap} data-markas-not-found-search>
          <svg class={searchIcon} {...svg}>
            <path d={paths.search.d} />
          </svg>
          <input
            type="search"
            aria-label={searchLabel}
            placeholder={searchLabel}
            class={searchInput}
          />
          {links.length > 0 && (
            <ul class={list}>
              {links.map((link) => (
                <li data-label={link.label.toLowerCase()}>
                  <a href={safeHref(link.href)} class={listLink}>
                    {link.label}
                    <svg class={arrow} {...svg}>
                      <path d={paths.arrow.d} />
                    </svg>
                  </a>
                </li>
              ))}
            </ul>
          )}
          <p role="status" class={empty} data-label={emptyLabel} />
        </div>
      )
    }
    <div class={actions}>
      <a href={safeHref(homeHref)} class:list={[button, primary]}>
        {homeLabel}
      </a>
      <a
        href={safeHref(homeHref)}
        data-markas-not-found-back
        class:list={[button, secondary]}
      >
        <svg class={backIcon} {...svg}><path d={paths.back.d} /></svg>
        {backLabel}
      </a>
    </div>
  </div>
</section>

<script>
  // One set of listeners per page serves every NotFound, including pages reached through
  // view transitions.
  document.addEventListener("click", (event) => {
    const back = (event.target as Element).closest?.(
      "[data-markas-not-found-back]",
    );
    // Go back to the previous page; without history the link simply goes to homeHref.
    if (!back || history.length < 2) return;
    event.preventDefault();
    history.back();
  });

  document.addEventListener("input", (event) => {
    const input = event.target;
    if (!(input instanceof HTMLInputElement)) return;
    const wrap = input.closest("[data-markas-not-found-search]");
    if (!wrap) return;
    const needle = input.value.trim().toLowerCase();
    let shown = 0;
    wrap.querySelectorAll<HTMLElement>("li[data-label]").forEach((item) => {
      const match = (item.dataset.label ?? "").includes(needle);
      item.hidden = !match;
      if (match) shown += 1;
    });
    const list = wrap.querySelector<HTMLElement>("ul");
    if (list) list.hidden = shown === 0;
    const status = wrap.querySelector<HTMLElement>("[role=status]");
    if (status)
      status.textContent =
        needle && shown === 0 ? (status.dataset.label ?? "") : "";
  });
</script>
```

```astro
---
import NotFound from "@/components/markas/NotFound.astro";
---

<NotFound />
<NotFound variant="search" links={links} />
<NotFound variant="glitch" code="500" title="Something went wrong" />
```

Go back dan filter pencarian memakai satu script kecil yang dibundel per halaman.

### Angular

Simpan di `src/app/markas/not-found.component.ts`. Tanpa dependensi tambahan.

```ts
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  input,
  signal,
  ViewEncapsulation,
} from "@angular/core";

const root =
  "@container grid w-full text-ink **:focus-visible:outline-2 **:focus-visible:outline-offset-2 **:focus-visible:outline-primary motion-reduce:**:animate-none motion-reduce:**:transition-none";
const centered = "mx-auto max-w-lg justify-items-center text-center";
const layouts = {
  minimal: centered,
  split: "items-center gap-8 @xl:grid-cols-2",
  search: centered,
  glitch: centered,
  illustrated: centered,
  terminal: "mx-auto max-w-xl gap-6",
};
const big = "mb-2 text-8xl leading-none font-semibold tracking-tighter";
const eyebrow =
  "rounded-full border border-line px-2.5 py-0.5 text-xs font-medium text-muted";
const codes: Record<string, string> = {
  minimal: big,
  glitch: `${big} relative before:absolute before:inset-0 before:animate-[markas-glitch_2s_steps(1)_infinite] before:text-danger before:content-[attr(data-text)] after:absolute after:inset-0 after:animate-[markas-glitch_1.5s_steps(1)_infinite_reverse] after:text-success after:content-[attr(data-text)] motion-reduce:before:hidden motion-reduce:after:hidden`,
  illustrated: `${big} relative grid *:col-start-1 *:row-start-1`,
  split: eyebrow,
  search: eyebrow,
};
const content = "grid w-full gap-4 [justify-items:inherit]";
const shadow = "translate-2.5 text-primary/15";
const outline = "text-transparent [-webkit-text-stroke:2px_var(--color-ink)]";
const compass =
  "absolute -top-4 -right-10 size-12 rotate-12 rounded-full bg-canvas p-1 text-muted";
const art = "order-last mx-auto w-full max-w-xs";
const artSoft = "fill-primary-soft";
const artStroke = "fill-surface stroke-line";
const artInk = "fill-subtle stroke-ink";
const titleClass = "text-3xl font-semibold tracking-tight text-balance";
const descriptionClass = "max-w-prose text-pretty text-muted";
const terminal =
  "rounded-xl border border-line bg-surface p-4 text-left font-mono text-sm";
const prompt = "text-muted";
const terminalTitle = "text-danger";
const cursor = "inline-block h-4 w-2 animate-pulse bg-ink align-middle";
const searchWrap = "relative w-full text-sm";
const searchIcon = "absolute top-3 left-3 size-4 text-muted";
const searchInput =
  "h-10 w-full rounded-lg border border-line bg-surface pr-3 pl-9 placeholder:text-faint";
const list =
  "mt-3 divide-y divide-line rounded-xl border border-line bg-surface text-left";
const listLink =
  "flex justify-between rounded-xl px-4 py-3 font-medium hover:bg-subtle";
const arrow = "size-4 text-muted";
const empty = "text-muted not-empty:mt-3";
const actions = "flex flex-wrap gap-3";
const button =
  "inline-flex h-10 items-center gap-2 rounded-lg px-4 text-sm font-medium transition-colors duration-150 ease-out";
const primary = "bg-primary text-on-primary hover:bg-primary-strong";
const secondary = "border border-line bg-surface hover:bg-subtle";
const backIcon = "size-4";
const keyframes =
  "@keyframes markas-glitch{0%{clip-path:inset(20% 0 55% 0);translate:-3px 1px}33%{clip-path:inset(60% 0 10% 0);translate:3px -1px}66%{clip-path:inset(35% 0 40% 0);translate:-2px 2px}}";

/** Hrefs with a scheme other than http, https, mailto, and tel (javascript: for one) become "#". Spaces and control characters are ignored, as browsers do. */
const safeHref = (href = "#") =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

export type NotFoundLink = { label: string; href: string };
export type NotFoundVariant = keyof typeof layouts;

let nextId = 0;

/**
 * Host stays out of layout; id, title, and class move to the section. The glitch keyframes are
 * a global style, so encapsulation is off.
 */
@Component({
  selector: "markas-not-found",
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
  styles: [keyframes],
  host: { class: "contents", "[attr.id]": "null", "[attr.title]": "null" },
  template: `
    <section
      [attr.id]="id() ?? null"
      [attr.aria-labelledby]="titleId()"
      [class]="rootClasses()"
    >
      @if (variant() === "split") {
        <svg viewBox="0 0 240 200" [class]="art" aria-hidden="true">
          <circle cx="150" cy="92" r="64" [class]="artSoft" />
          <rect
            x="34"
            y="48"
            width="92"
            height="92"
            rx="14"
            stroke-width="2"
            [class]="artStroke"
          />
          <path d="M60 176 108 96l48 80z" stroke-width="2" [class]="artInk" />
        </svg>
      }
      @if (variant() === "terminal") {
        <div [class]="terminal">
          <p><span [class]="prompt">$ </span>cd {{ path() }}</p>
          <h1 [id]="titleId()" [class]="terminalTitle">
            {{ code() }}: {{ title() }}
          </h1>
          <p aria-hidden="true">
            <span [class]="prompt">$ </span><span [class]="cursor"></span>
          </p>
        </div>
      }
      <div [class]="content">
        @if (codeClass()) {
          <p aria-hidden="true" [attr.data-text]="code()" [class]="codeClass()">
            @if (variant() === "illustrated") {
              <span [class]="shadow">{{ code() }}</span
              ><span [class]="outline">{{ code() }}</span
              ><svg
                [class]="compass"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="1.5"
                stroke-linecap="round"
                stroke-linejoin="round"
                aria-hidden="true"
              >
                <path
                  d="M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zm4.2-14.2-2.1 6.3-6.3 2.1 2.1-6.3z"
                />
              </svg>
            } @else {
              {{ code() }}
            }
          </p>
        }
        @if (variant() !== "terminal") {
          <h1 [id]="titleId()" [class]="titleClass">{{ title() }}</h1>
        }
        <p [class]="descriptionClass">{{ description() }}</p>
        @if (variant() === "search") {
          <div [class]="searchWrap">
            <svg
              [class]="searchIcon"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="1.5"
              stroke-linecap="round"
              stroke-linejoin="round"
              aria-hidden="true"
            >
              <path d="m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z" />
            </svg>
            <input
              #field
              type="search"
              [attr.aria-label]="searchLabel()"
              [placeholder]="searchLabel()"
              [value]="query()"
              (input)="query.set(field.value)"
              [class]="searchInput"
            />
            @if (visible().length) {
              <ul [class]="list">
                @for (link of visible(); track link.href) {
                  <li>
                    <a [href]="safeHref(link.href)" [class]="listLink"
                      >{{ link.label
                      }}<svg
                        [class]="arrow"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        stroke-width="1.5"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        aria-hidden="true"
                      >
                        <path d="M5 12h14m-6-6 6 6-6 6" /></svg
                    ></a>
                  </li>
                }
              </ul>
            }
            <p role="status" [class]="empty">{{ emptyMessage() }}</p>
          </div>
        }
        <div [class]="actions">
          <a [href]="home()" [class]="primaryClasses">{{ homeLabel() }}</a>
          <a [href]="home()" [class]="secondaryClasses" (click)="goBack($event)"
            ><svg
              [class]="backIcon"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="1.5"
              stroke-linecap="round"
              stroke-linejoin="round"
              aria-hidden="true"
            >
              <path d="M19 12H5m6 6-6-6 6-6" /></svg
            >{{ backLabel() }}</a
          >
        </div>
      </div>
    </section>
  `,
})
export class NotFound {
  /** minimal, split, search, glitch, illustrated, or terminal. */
  readonly variant = input<NotFoundVariant>("minimal");
  /** Status code, for example 404, 403, or 500. */
  readonly code = input("404");
  readonly title = input("Page not found");
  readonly description = input(
    "The page you are looking for does not exist or has been moved.",
  );
  readonly homeHref = input("/");
  /** Popular links that can be filtered in the search variant. */
  readonly links = input<NotFoundLink[]>([]);
  /** Path shown in the terminal variant. */
  readonly path = input("/page");
  readonly homeLabel = input("Back to home");
  readonly backLabel = input("Go back");
  readonly searchLabel = input("Search pages");
  readonly emptyLabel = input("No pages match your search");
  readonly id = input<string>();
  readonly userClass = input("", { alias: "class" });

  protected readonly art = art;
  protected readonly artSoft = artSoft;
  protected readonly artStroke = artStroke;
  protected readonly artInk = artInk;
  protected readonly terminal = terminal;
  protected readonly prompt = prompt;
  protected readonly terminalTitle = terminalTitle;
  protected readonly cursor = cursor;
  protected readonly content = content;
  protected readonly shadow = shadow;
  protected readonly outline = outline;
  protected readonly compass = compass;
  protected readonly titleClass = titleClass;
  protected readonly descriptionClass = descriptionClass;
  protected readonly searchWrap = searchWrap;
  protected readonly searchIcon = searchIcon;
  protected readonly searchInput = searchInput;
  protected readonly list = list;
  protected readonly listLink = listLink;
  protected readonly arrow = arrow;
  protected readonly empty = empty;
  protected readonly actions = actions;
  protected readonly backIcon = backIcon;
  protected readonly primaryClasses = `${button} ${primary}`;
  protected readonly secondaryClasses = `${button} ${secondary}`;
  protected readonly safeHref = safeHref;

  protected readonly query = signal("");
  private readonly generatedId = `markas-not-found-${nextId++}`;
  protected readonly titleId = computed(
    () => `${this.id() ?? this.generatedId}-title`,
  );
  protected readonly rootClasses = computed(() =>
    [root, layouts[this.variant()], this.userClass()].filter(Boolean).join(" "),
  );
  protected readonly codeClass = computed(() => codes[this.variant()] ?? "");
  protected readonly home = computed(() => safeHref(this.homeHref()));
  private readonly needle = computed(() => this.query().trim().toLowerCase());
  protected readonly visible = computed(() =>
    this.links().filter((link) =>
      link.label.toLowerCase().includes(this.needle()),
    ),
  );
  protected readonly emptyMessage = computed(() =>
    this.needle() && !this.visible().length ? this.emptyLabel() : "",
  );

  /** Go back to the previous page; without history the link simply goes to homeHref. */
  protected goBack(event: MouseEvent) {
    if (history.length < 2) return;
    event.preventDefault();
    history.back();
  }
}
```

```ts
import { Component } from "@angular/core";
import { NotFound } from "./markas/not-found.component";

@Component({
  selector: "app-not-found-page",
  imports: [NotFound],
  template: `
    <markas-not-found />
    <markas-not-found variant="search" [links]="links" />
    <markas-not-found
      variant="glitch"
      code="500"
      title="Something went wrong"
    />
  `,
})
export class NotFoundPage {
  links = [
    { label: "Documentation", href: "/docs" },
    { label: "Pricing", href: "/pricing" },
  ];
}
```

## Props

| Nama | Tipe | Default | Keterangan |
| --- | --- | --- | --- |
| `variant` | `"minimal" \| "split" \| "search" \| "glitch" \| "illustrated" \| "terminal"` | "minimal" | Tata letak. minimal: kode besar di atas teks. split: teks kiri, SVG geometris kanan mulai lebar 36rem. search: kotak cari di atas tautan yang bisa disaring. glitch: kode dengan efek glitch CSS. illustrated: kode outline bertumpuk dengan kompas. terminal: jendela shell. |
| `code` | `string` | "404" | Kode status di visual, misalnya 403 atau 500. |
| `title` | `string` | "Page not found" | Judul (h1) yang menyebut masalahnya. |
| `description` | `string` | "The page you are looking for does not exist or has been moved." | Penjelasan singkat di bawah judul. |
| `homeHref` | `string` | "/" | Tujuan link beranda, juga link Kembali bila tidak ada riwayat. |
| `links` | `{ label, href }[]` | [] | Halaman populer. Tampil dan bisa disaring di variant search. |
| `path` | `string` | "/page" | Path yang diketik setelah cd di variant terminal. |
| `homeLabel` | `string` | Back to home | Teks link beranda. Isi "Kembali ke beranda" untuk situs berbahasa Indonesia. |
| `backLabel` | `string` | Go back | Teks link kembali di riwayat. Isi "Kembali" untuk situs berbahasa Indonesia. |
| `searchLabel` | `string` | Search pages | Label aksesibel dan placeholder kotak cari. Isi "Cari halaman" untuk situs berbahasa Indonesia. |
| `emptyLabel` | `string` | No pages match your search | Pesan yang diumumkan saat pencarian kosong. Isi "Tidak ada halaman yang cocok" untuk situs berbahasa Indonesia. |

## Aksesibilitas

- Blok berupa section yang diberi label oleh judul h1. Kode dekoratif, ilustrasi, dan lapisan glitch memakai aria-hidden.
- Kembali adalah link sungguhan ke homeHref: dengan JavaScript dan riwayat ia memanggil history.back(), selain itu langsung ke beranda.
- Kotak cari punya label aksesibel; pesan hasil kosong ada di live region role=status.
- Lapisan glitch disembunyikan dan kursor berhenti berkedip dengan prefers-reduced-motion.

## Catatan

- Blok ini merender h1, jadi pakai sebagai isi utama halaman error.
- Kembali adalah link ke `homeHref`. Bila ada riwayat browser, ia memanggil `history.back()`.
- Variant split menampilkan ilustrasi di samping teks mulai lebar 36rem (container query) dan di bawahnya di layar sempit.
