NavItem
Navigation item — a prop-driven link that highlights the current route via
isCurrent and defers routing to a renderLink seam. Domain-agnostic: no
router, no i18n; the caller owns the label and the link element.
import { NavItem } from "@evolve-storefront/ui/nav-item";Preview
Usage
A link in a navigation list. isCurrent marks the page being shown; Nav has one.
<NavItem href="/account/addresses">{t("addresses")}</NavItem>;Props
| Prop | Type | Description |
|---|---|---|
href | string | |
children | ReactNode | |
isCurrent? | boolean | This item is the current route: highlights it and sets |
renderLink? | ((props: NavItemRenderProps) => ReactNode) | Render the link with the app's router (e.g. Next |
Any other props go to the root element, like on a plain HTML element.
Examples
Nav
<nav> {links.map((link) => ( <NavItem key={link.href} href={link.href} isCurrent={pathname === link.href}> {t(link.label)} </NavItem> ))}</nav>;Custom Link
// Bind the app's router link; NavItem supplies href, className and aria-current.<NavItem href="/account" isCurrent renderLink={(props) => <Link {...props} />}> {t("myDetails")}</NavItem>;Target SizeThe link is a block of at least 24px whatever padding a brand gives it, so the whole row is the link and a pointer target, not just its label.
<NavItem href="/account/addresses" className="py-0"> {t("addresses")}</NavItem>;Block Link In ListA link in a list item: the whole row is the link, not just its label.
<ul> {links.map((link) => ( <li key={link.href}> <NavItem href={link.href}> {t(link.label)} </NavItem> </li> ))}</ul>;
