HextaUI

Navigation menu: Current page

Links in the bar look like triggers. Mark the current page with active, which also sets aria-current="page".

import {
  NavigationMenu,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
} from "@/components/ui/navigation-menu"

const links = ["Overview", "Activity", "Settings"]

export function NavigationMenuActive() {
  return (
    <NavigationMenu aria-label="Project">
      <NavigationMenuList>
        {links.map((link) => (
          <NavigationMenuItem key={link}>
            <NavigationMenuLink href="#" active={link === "Activity"}>
              {link}
            </NavigationMenuLink>
          </NavigationMenuItem>
        ))}
      </NavigationMenuList>
    </NavigationMenu>
  )
}

This adds the example as components/examples/navigation-menu/active.tsx, together with the Navigation menu component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/navigation-menu-active.json

To add only the component, follow the Navigation menu installation.

Props in this example

The Navigation menu props this example sets, from the API reference.

PropTypeDefault
activeMarks the current page.
booleanfalse

Every prop is in the Navigation menu API reference.

See them all, with keyboard support and accessibility notes, on the Navigation menu page.