bearnie

Navigation Menu

A site navigation bar with hoverable dropdown panels of links.

Installation

npx bearnie add navigation-menu
npx bearnie add navigation-menu

Usage

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

Panels open on hover or click and close when the pointer or focus leaves. Items without a panel are plain links — use variant="trigger" on NavigationMenuLink so they match the trigger styling. Mark the current page with active to get aria-current="page" and a highlighted state.

Examples

Centered panel

align="center" centers the panel under its trigger; align="end" right-aligns it — useful for the last item so the panel doesn’t overflow the viewport.

Anatomy

  • NavigationMenu — the <nav> root; owns the open/close behavior.
  • NavigationMenuList — a <ul> holding the items.
  • NavigationMenuItem — a <li>; contains either a trigger + content pair or a plain link.
  • NavigationMenuTrigger — the button with a rotating chevron.
  • NavigationMenuContent — the panel, hidden until its trigger is hovered, clicked, or focused.
  • NavigationMenuLink — a styled link for panels (variant="default") or the top bar (variant="trigger").

Props

Component Prop Type Default Description
NavigationMenuContent align “start” | “center” | “end” “start” Panel alignment relative to the item
NavigationMenuLink href string - Link destination (required)
NavigationMenuLink variant “default” | “trigger” “default” Panel link or top-bar link styling
NavigationMenuLink active boolean false Sets aria-current="page" and a highlighted state

All components accept class and forward standard HTML attributes.

Accessibility

  • Triggers expose aria-expanded and data-state="open|closed" for styling.
  • ArrowDown on a trigger opens the panel and focuses the first link; ArrowUp/ArrowDown cycle links inside a panel; Escape closes and restores trigger focus.
  • Panels stay open while focus is inside them, so keyboard users can Tab through the links.