Dev Helpers
← Back

Current page navigation

Import and render <CurrentPageNavigation /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/CurrentPageNavigation.tsx

export default function CurrentPageNavigation({
  links = [
    { label: "Guide", href: "/guide" },
    { label: "About", href: "/about" },
  ],
  current = "/guide",
}: { links?: { label: string; href: string }[]; current?: string } = {}) {
  return (
    <nav aria-label="Primary">
      {links.map((l) => (
        <a
          key={l.href}
          href={l.href}
          aria-current={l.href === current ? "page" : undefined}
        >
          {l.label}{" "}
        </a>
      ))}
    </nav>
  );
}