Navigation Menu
A wrapper for Base UI Navigation Menu — horizontal nav with trigger+content dropdowns, direct link items, hover support, and controlled state.
Installation
npx shadcn@latest add @glrk-ui/navigation-menuIf you haven't set up the prerequisites yet, check out registry setup.
Usage
Trigger item (with dropdown content)
import { NavigationMenuWrapper, NavList } from "@/components/ui/navigation-menu-wrapper"
<NavigationMenuWrapper
items={[
{
key: "products",
trigger: "Products",
content: (
<div className="p-4 w-64">
<NavList
items={[
{ href: "/analytics", children: "Analytics" },
{ href: "/reporting", children: "Reporting" },
]}
/>
</div>
),
},
]}
/>Link item (no dropdown)
<NavigationMenuWrapper
items={[
{ key: "pricing", href: "/pricing", children: "Pricing" },
{ key: "blog", href: "/blog", children: "Blog" },
]}
/>Mixed (triggers + links)
<NavigationMenuWrapper
items={[
{
key: "home",
trigger: "Home",
content: <div className="p-4"><NavList items={[...]} /></div>,
},
{ key: "pricing", href: "/pricing", children: "Pricing" },
]}
/>Group labels in content
{
key: "platform",
trigger: "Platform",
content: (
<div className="p-3 w-72">
<p className="mb-1 text-xs font-semibold text-muted-foreground uppercase tracking-wide">
Tools
</p>
<NavList items={[{ href: "/formatter", children: "Formatter" }]} />
<p className="mt-3 mb-1 text-xs font-semibold text-muted-foreground uppercase tracking-wide">
Security
</p>
<NavList items={[{ href: "/audit", children: "Audit Log" }]} />
</div>
),
}Default open
<NavigationMenuWrapper
defaultValue="products"
items={[
{ key: "products", trigger: "Products", content: <div>...</div> },
]}
/>Hover delay (instant open on hover)
Base UI Navigation Menu opens on hover by default (50ms delay). Adjust with delay and closeDelay:
<NavigationMenuWrapper
delay={0}
closeDelay={150}
items={[...]}
/>Controlled (external open/close)
const [value, setValue] = useState<string | null>(null)
<NavigationMenuWrapper
value={value}
onValueChange={v => setValue(v)}
items={[
{ key: "tools", trigger: "Tools", content: <div>...</div> },
]}
/>
// Close programmatically:
<button onClick={() => setValue(null)}>Close</button>
// Open specific item:
<button onClick={() => setValue("tools")}>Open Tools</button>Per-item trigger props
{
key: "products",
trigger: "Products",
triggerCls: "font-semibold",
triggerProps: { disabled: true },
contentCls: "w-96",
content: <div>...</div>,
}NavList helper
import { NavList } from "@/components/ui/navigation-menu-wrapper"
<NavList
wrapperCls="space-y-1"
items={[
{ href: "/dashboard", children: "Dashboard" },
{ href: "/settings", children: <><SettingsIcon className="size-4" /> Settings</> },
]}
/>NavLinkItem helper
import { NavLinkItem } from "@/components/ui/navigation-menu-wrapper"
<NavLinkItem href="/dashboard">Dashboard</NavLinkItem>Router links
Links render a plain <a> by default. Pass your router's link component for client-side navigation:
import Link from "next/link" // or react-router, TanStack Router, …
<NavigationMenuWrapper linkAs={Link} items={items} />
<NavList linkAs={Link} items={links} />
<NavLinkItem linkAs={Link} href="/dashboard">Dashboard</NavLinkItem>