Skip to Content
Neshel-UI
Components

Navbar

A header bar with brand, navigation links and actions, responsive with a MobileMenu.

Server-compatible (no "use client")

Purpose

Navbar is a site or application header: a <header> with a brand, a <nav> list of links and an actions area. Its parts are server-compatible.

Import

import.tsx
import {
  Navbar,
  NavbarActions,
  NavbarBrand,
  NavbarLink,
  NavbarNav,
} from "@neshel-ui/components";

Usage

Preview: navbar-responsive
Preview theme
navbar-responsive.tsx
import {
  Button,
  MobileMenu,
  MobileMenuContent,
  MobileMenuLink,
  MobileMenuNav,
  MobileMenuTrigger,
  Navbar,
  NavbarActions,
  NavbarBrand,
  NavbarLink,
  NavbarNav,
} from "@neshel-ui/components";

const links = [
  { href: "#home", label: "Home", active: true },
  { href: "#docs", label: "Docs" },
  { href: "#blog", label: "Blog" },
];

/** Desktop links from md; below md the MobileMenu trigger replaces them (never both). */
export default function NavbarResponsive() {
  return (
    <Navbar>
      <NavbarBrand asChild>
        <a href="#home">Acme</a>
      </NavbarBrand>
      <NavbarNav hideBelow="md">
        {links.map((link) => (
          <NavbarLink key={link.href} href={link.href} active={link.active}>
            {link.label}
          </NavbarLink>
        ))}
      </NavbarNav>
      <NavbarActions>
        <Button size="sm">Sign in</Button>
        <MobileMenu breakpoint="md">
          <MobileMenuTrigger />
          <MobileMenuContent>
            <MobileMenuNav>
              {links.map((link) => (
                <MobileMenuLink key={link.href} href={link.href} active={link.active}>
                  {link.label}
                </MobileMenuLink>
              ))}
            </MobileMenuNav>
          </MobileMenuContent>
        </MobileMenu>
      </NavbarActions>
    </Navbar>
  );
}

API

NavbarProps

NavbarProps
PropTypeDefaultDescription
refRef<HTMLElement>——
stickyboolean—Stick to the top of the scroll container.

Also accepts the props of: React DOM attributes.

NavbarBrandProps

NavbarBrandProps
PropTypeDefaultDescription
asChildboolean—Render the single child (e.g. a home link) with the brand styles.
refRef<HTMLElement>——

Also accepts the props of: React DOM attributes.

NavbarNavProps

NavbarNavProps
PropTypeDefaultDescription
hideBelowBreakpoint—Hide the links below this breakpoint (pair with a MobileMenu using the same breakpoint).
refRef<HTMLElement>——

Also accepts the props of: React DOM attributes.

NavbarLinkProps

NavbarLinkProps
PropTypeDefaultDescription
activeboolean—The current page: sets aria-current="page".
asChildboolean—Render the single child element (e.g. a router link) inside the <li> instead of an <a>.
refRef<HTMLAnchorElement>——

Also accepts the props of: React DOM attributes.

NavbarActionsProps

NavbarActionsProps
PropTypeDefaultDescription
refRef<HTMLDivElement>——

Also accepts the props of: React DOM attributes.

PartRenders
Navbar<header>; sticky keeps it at the top
NavbarBranddiv, or your link with asChild
NavbarNav<nav aria-label="Main"> with a <ul>; hideBelow (responsive)
NavbarLink<li> with an <a> (or your router link with asChild)
NavbarActionsdiv for buttons and menus

Responsive behaviour

<NavbarNav hideBelow="md"> hides the links below md; <MobileMenu breakpoint="md"> shows its trigger only below md. Use the same breakpoint and exactly one is visible at any width — decided by CSS, so there is no hydration flash.

Accessibility

  • active sets aria-current="page" on the current link.
  • Give NavbarNav a distinct aria-label if the page has several <nav> elements.
  • --neshel-navbar-height (default 3.5rem) sets the bar height.

Common mistakes

  • Putting dropdown commands among the links: use a DropdownMenu in NavbarActions, and NavigationMenu for panels of links.
  • Mismatched hideBelow and MobileMenu breakpoint, showing both or neither.
Edit on GitHub

On this page