A single navigation link with an optional leading icon and active state. The `active` modifier is applied on the component's own root element (per BEM), so it can be dropped into any nav/sidebar layout.

pnpm add @behivetech/atoms.nav-item

You are viewing Nav Item v0.5.1, snapshotted 2026-11-10. The latest is v0.5.2. Go to the latest →

A single navigation link with an optional leading icon and active state. The active modifier is applied on the component's own root element (per BEM), so it can be dropped into any nav/sidebar layout.

Usage

1import { NavItem } from "@behivetech/atoms.nav-item";
2
3function Example() {
4 const currentPath = "/pages";
5 return (
6 <NavItem href="/pages" icon="☰" active={currentPath.startsWith("/pages")}>
7 Pages
8 </NavItem>
9 );
10}

Properties

NavItem props

PropTypeDefaultDescription
activebooleanfalseWhether this item represents the current route: adds the `--active` modifier and sets `aria-current="page"` unless you pass your own `aria-current`.
asChildbooleanfalseRenders the item's props onto its single child element (via Radix `Slot`) instead of an `<a>`, so a router link such as Next's `Link` can be the element. The child supplies the content, so `icon` is ignored.
childrenReactNode—Content to render inside the component
classNamestring—Additional class names to merge with the component root element
iconReactNode—Leading icon rendered before the content

Also accepts the native attributes of its root element (className, aria-*, event handlers, …).