Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Navigation

Navbar

Free24.9 KB gzipped

The top header of an app or site. Renders a <header> (a banner landmark when it isn't inside main, article, aside, nav, or section) with brand, navigation, and actions. Below collapseBelow the navigation moves into a modal drawer opened by a menu button.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Enter, Space and 1 more · Full report

Import

tsx
import { Navbar } from "@vjdesigns/vjdesigns-ui";

Importing only Navbar adds about 24.9 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

Brand, navigation and actions. Below collapseBelow the links move into a drawer opened by a menu button. Resize your window to see it. Pass your router's link component as as.

tsx
import { useState } from "react";
import { Avatar, Box, Button, Navbar } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  const [page, setPage] = useState("overview");
  const link = (id: string, label: string) => (
    <Navbar.Link
      href={`#${id}`}
      active={page === id}
      onClick={(event) => {
        event.preventDefault();
        setPage(id);
      }}
    >
      {label}
    </Navbar.Link>
  );

  return (
    <Box radius="lg" border overflow="hidden" style={{ width: "100%" }}>
      <Navbar position="static" contained={false} collapseBelow="md" menuTitle="Acme">
        <Navbar.Brand href="#example-basic">Acme</Navbar.Brand>
        <Navbar.Nav aria-label="Example">
          {link("overview", "Overview")}
          {link("projects", "Projects")}
          {link("reports", "Reports")}
        </Navbar.Nav>
        <Navbar.Actions>
          <Button size="sm" variant="ghost" tone="neutral">
            Help
          </Button>
          <Avatar name="Jordan Lee" size="sm" colorFromName />
        </Navbar.Actions>
      </Navbar>
    </Box>
  );
}

Solid

variant="solid" fills the bar with the primary color.

tsx
import { Box, Navbar } from "@vjdesigns/vjdesigns-ui";

export function Solid() {
  return (
    <Box radius="lg" overflow="hidden" style={{ width: "100%" }}>
      <Navbar position="static" variant="solid" contained={false} size="sm" collapseBelow="sm" menuTitle="Northwind">
        <Navbar.Brand href="#example-solid">Northwind</Navbar.Brand>
        <Navbar.Nav align="end" aria-label="Solid example">
          <Navbar.Link href="#example-solid" active>
            Home
          </Navbar.Link>
          <Navbar.Link href="#example-solid">Pricing</Navbar.Link>
          <Navbar.Link href="#example-solid">About</Navbar.Link>
        </Navbar.Nav>
      </Navbar>
    </Box>
  );
}

Groups

Navbar.Group puts links under one button that opens a dropdown, or an expandable section in the mobile menu. It's a disclosure, not a menu, so its links stay ordinary links in the Tab order. Escape, a press outside, tabbing out or choosing a link closes it, and opening one group closes the other. active marks the group that holds the current page.

Acme
tsx
import { useState } from "react";
import { Box, Navbar } from "@vjdesigns/vjdesigns-ui";

export function Groups() {
  const [page, setPage] = useState("season");
  const link = (id: string, label: string) => (
    <Navbar.Link
      href={`#${id}`}
      active={page === id}
      onClick={(event) => {
        event.preventDefault();
        setPage(id);
      }}
    >
      {label}
    </Navbar.Link>
  );

  return (
    <Box radius="lg" border style={{ width: "100%" }}>
      <Navbar position="static" contained={false} collapseBelow="md" menuTitle="Acme">
        <Navbar.Brand href="#example-groups">Acme</Navbar.Brand>
        <Navbar.Nav aria-label="Groups example">
          {link("home", "Home")}
          <Navbar.Group label="Reports" active={page === "season" || page === "players"}>
            {link("season", "Season")}
            {link("players", "Players")}
          </Navbar.Group>
          <Navbar.Group label="Teams" active={page === "varsity" || page === "jv"}>
            {link("varsity", "Varsity")}
            {link("jv", "Junior varsity")}
          </Navbar.Group>
        </Navbar.Nav>
      </Navbar>
    </Box>
  );
}

Badges

badge on Navbar.Link or Navbar.Group shows a count (capped at 99+, hidden at 0) or a short text after the label, in the bar and the mobile menu. badgeLabel gives screen readers the full meaning ("Messages, 3 unread messages"). On the solid bar, a badge without a badgeTone swaps the bar's colors so it stands out in both themes.

tsx
import { Box, Flex, Navbar } from "@vjdesigns/vjdesigns-ui";

export function Badges() {
  return (
    <Flex direction="column" gap={3} style={{ width: "100%" }}>
      {(["surface", "solid"] as const).map((variant) => (
        <Box key={variant} radius="lg" border={variant === "surface"} overflow="hidden">
          <Navbar position="static" variant={variant} contained={false} size="sm" collapseBelow="sm" menuTitle="Acme">
            <Navbar.Brand href="#example-badges">Acme</Navbar.Brand>
            <Navbar.Nav aria-label={`Badges example, ${variant}`}>
              <Navbar.Link href="#example-badges" active>
                Home
              </Navbar.Link>
              <Navbar.Link href="#example-badges" badge={3} badgeLabel="3 unread messages">
                Messages
              </Navbar.Link>
              <Navbar.Link href="#example-badges" badge={120} badgeTone="danger" badgeLabel="120 alerts">
                Alerts
              </Navbar.Link>
              <Navbar.Link href="#example-badges" badge="New">
                Playbook
              </Navbar.Link>
            </Navbar.Nav>
          </Navbar>
        </Box>
      ))}
    </Flex>
  );
}

Active tone

activeTone colors the active link's pill and indicator bar: "accent" (the default), "primary" to follow the brand, or "neutral" for a quieter gray.

tsx
import { Box, Flex, Navbar } from "@vjdesigns/vjdesigns-ui";

export function ActiveTone() {
  return (
    <Flex direction="column" gap={3} style={{ width: "100%" }}>
      {(["accent", "primary", "neutral"] as const).map((tone) => (
        <Box key={tone} radius="lg" border overflow="hidden">
          <Navbar position="static" contained={false} size="sm" collapseBelow="sm" menuTitle={tone} activeTone={tone}>
            <Navbar.Brand href="#example-active-tone">{tone}</Navbar.Brand>
            <Navbar.Nav aria-label={`${tone} example`}>
              <Navbar.Link href="#example-active-tone" active>
                Home
              </Navbar.Link>
              <Navbar.Link href="#example-active-tone">Pricing</Navbar.Link>
              <Navbar.Link href="#example-active-tone">About</Navbar.Link>
            </Navbar.Nav>
          </Navbar>
        </Box>
      ))}
    </Flex>
  );
}

Accessibility

Every Navbar.Nav is a navigation landmark: give each one a distinct aria-label so landmark lists read "Primary" and "Account" rather than "navigation" twice. active sets aria-current="page", and below collapseBelow the menu button (named by menuLabel) opens the links in a drawer named by menuTitle.

tsx
import { useState } from "react";
import { Box, Navbar } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  const [page, setPage] = useState("docs");
  const link = (id: string, label: string) => (
    <Navbar.Link
      href={`#${id}`}
      active={page === id}
      onClick={(event) => {
        event.preventDefault();
        setPage(id);
      }}
    >
      {label}
    </Navbar.Link>
  );
  return (
    <Box radius="lg" border overflow="hidden" style={{ width: "100%" }}>
      <Navbar position="static" contained={false} collapseBelow="lg" menuTitle="Acme menu" menuLabel="Open the Acme menu">
        <Navbar.Brand href="#example-accessibility">Acme</Navbar.Brand>
        <Navbar.Nav aria-label="Primary">
          {link("docs", "Docs")}
          {link("blog", "Blog")}
        </Navbar.Nav>
        <Navbar.Nav aria-label="Account" align="end">
          {link("signin", "Sign in")}
        </Navbar.Nav>
      </Navbar>
    </Box>
  );
}

Translated

The menu button's name and the drawer's close button come from the locale (Spanish here); the links and the drawer's title are your own text. Make the window narrow to open the drawer.

tsx
import { Box, Navbar, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import es from "@vjdesigns/vjdesigns-ui/locales/es";

export function Translated() {
  return (
    <LocaleProvider locale="es" messages={es}>
      <Box radius="lg" border overflow="hidden" style={{ width: "100%" }}>
        <Navbar position="static" contained={false} collapseBelow="lg" menuTitle="Menú de Acme">
          <Navbar.Brand href="#example-translated">Acme</Navbar.Brand>
          <Navbar.Nav aria-label="Principal">
            <Navbar.Link href="#example-translated" active>
              Inicio
            </Navbar.Link>
            <Navbar.Link href="#example-translated">Productos</Navbar.Link>
            <Navbar.Link href="#example-translated">Contacto</Navbar.Link>
          </Navbar.Nav>
        </Navbar>
      </Box>
    </LocaleProvider>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

Usage notes

tsx
<Navbar>
  <Navbar.Brand href="/">Hoops</Navbar.Brand>
  <Navbar.Nav>
    <Navbar.Link href="/" active>Home</Navbar.Link>
    <Navbar.Link href="/teams">Teams</Navbar.Link>
  </Navbar.Nav>
  <Navbar.Actions>
    <Button size="sm">Sign in</Button>
  </Navbar.Actions>
</Navbar>

API reference

Navbar

Navbar props
PropTypeDefault
children

Navbar.Brand, Navbar.Nav, and Navbar.Actions, in that order.

ReactNode—
variant

Visual style. See NavbarVariant.

"surface""transparent""solid""surface"
size

Bar height, link size, and menu button size. sm 56px, md 64px, lg 80px tall.

"sm""md""lg""md"
position

sticky stays at the top of its scroll container; fixed stays at the top of the viewport (add top padding to the page); static scrolls away.

"static""sticky""fixed""sticky"
reserveScrollPadding

Keeps focused and scrolled-to content clear of a sticky or fixed bar (WCAG 2.4.11): while mounted, sets scroll-padding-top on the bar's scroll container to the bar's height, and restores it on unmount. Set false to manage it yourself, e.g. html { scroll-padding-top: var(--header-height) } (the md bar's height). Inside the bar, --navbar-height holds its height.

booleantrue
bordered

Draws a hairline under the bar.

booleanfalse
elevated

Always shows a soft shadow under the bar.

booleanfalse
elevateOnScroll

Shows the soft shadow only once the window has scrolled (a passive, frame-throttled listener). A transparent bar also fills with the surface color so links stay readable over content.

booleanfalse
contained

Centers the content in a max-width Container with responsive gutters. When false, the content spans the full width (gutters are kept). To compose your own layout instead, set contained={false}.

booleantrue
maxWidth

Max width of the content when contained.

"xs""sm""md""lg""xl""2xl""full""prose""xl"
collapseBelow

Below this breakpoint (sm 640px, md 768px, lg 1024px), Navbar.Nav is hidden and a menu button opens the links in a drawer instead.

"sm""md""lg""md"
open

Controlled open state of the mobile menu.

boolean—
defaultOpen

Initial open state of the mobile menu when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state whenever the mobile menu opens or closes.

(open: boolean) => void—
menuLabel

Accessible name of the menu button. Localize it here.

string"Open menu"
menuTitle

Title of the mobile menu drawer (it names the dialog).

ReactNode"Menu"
menuSide

Edge the mobile menu slides in from.

"start""end""end"
activeToneNew in 1.4.10

Color of the active link's pill and indicator bar, in the bar and the mobile menu: accent (the theme's accent), primary (the brand color), or neutral. The solid variant always marks the active link with the on-primary color.

"accent""primary""neutral""accent"

Also accepts native <header> attributes, plus className, style and ref.

Navbar.Brand

The logo or product name at the start of the bar, usually a link home.

Navbar.Brand props
PropTypeDefault
as

Component or element to render. Defaults to a when href is set, otherwise div. Pass a router link (e.g. React Router or Next.js Link) and its props (such as to) are accepted; it must forward className and ARIA props to its <a>.

ElementType—
children

Logo and/or product name. A logo-only brand link needs an aria-label (e.g. "Acme home").

ReactNode—

Navbar.Nav

Navbar.Nav props
PropTypeDefault
children

Navbar.Links (each is wrapped in an <li> for you) and/or Navbar.Items.

ReactNode—
align

Where the links sit in the bar, between the brand and the actions: start (next to the brand; left in left-to-right layouts), center, or end (next to the actions; right in left-to-right layouts). Logical, so it flips in right-to-left layouts. The mobile drawer always lists them vertically.

"start""center""end""start"
gap

Space between the links in the bar, as a spacing step (4 is --space-4, 16px). Accepts one value or one per breakpoint, e.g. { base: 2, xl: 6 }. The mobile drawer keeps its own vertical spacing.

Responsive<Space>1
aria-label

Names the navigation landmark. Give each <nav> on a page a distinct name.

string"Main"

Also accepts native <nav> attributes, plus className, style and ref.

Navbar.Item

Navbar.Item props
PropTypeDefault
children

A Navbar.Link, or any other control (e.g. a Button) that belongs in the list.

ReactNode—
showIn

Where the item appears. Navbar.Nav renders its children twice (in the bar and in the drawer), so a stateful child (a Menu, a toggle) is mounted twice and its drawer copy resets each time the drawer opens. Show such an item in one place only, or put it in Navbar.Actions.

"both""bar""drawer""both"

Also accepts native <li> attributes, plus className, style and ref.

A primary navigation link. Wraps itself in an <li> unless it's already inside Navbar.Item. In the mobile drawer, clicking it closes the drawer (even if a router prevents the default navigation).

It renders once in the bar and once in the drawer (only one is ever exposed), so don't give it an id. A ref attaches to the bar's copy.

Navbar.Link props
PropTypeDefault
as

Component or element to render. Defaults to a. Pass a router link (e.g. React Router or Next.js Link) and its props (such as to) are accepted and typed. It must forward className, onClick, and ARIA props to its <a>.

ElementType—
active

Marks the link as the current page: sets aria-current="page" and shows a filled pill with an indicator bar, so the state never relies on color alone.

booleanfalse
icon

Decorative icon before the label. Hidden from assistive technology.

ReactNode—
badgeNew in 2.4.0

A count (rendered with Badge count, capped at 99+, hidden at 0) or a short text such as "New", after the label. It's part of the link's name ("Messages 3"), in the bar and the mobile menu.

NavbarBadgeValue—
badgeLabelNew in 2.4.0

Screen-reader text for the badge, e.g. "3 unread messages". Replaces the visible badge text in the accessible name.

string—
badgeToneNew in 2.4.0

Badge color. By default accent, except in the solid bar, where the badge takes the bar's own colors swapped (a Badge variant="inverse") so it stands out from the bar in both themes. Setting it always gives a solid badge in that tone.

"neutral""primary""accent""success""warning""danger""info"—
children

The visible label.

ReactNode—

Navbar.Group

New in 2.4.0
Navbar.Group props
PropTypeDefault
labelRequired

The group button's visible label, and its accessible name.

ReactNode—
icon

Decorative icon before the label.

ReactNode—
children

The group's Navbar.Links.

ReactNode—
active

One of the group's links is the current page. The button then shows the active look (it doesn't set aria-current; the link does), and the group starts open in the mobile menu.

booleanfalse
badge

A count or short text on the group button, like Navbar.Link's badge.

NavbarBadgeValue—
badgeLabel

Screen-reader text for the badge.

string—
badgeTone

Badge color. Same default as Navbar.Link's badgeTone (inverse on the solid bar).

"neutral""primary""accent""success""warning""danger""info"—
open

Controlled open state of the dropdown in the bar.

boolean—
defaultOpen

Initial open state of the dropdown when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state of the dropdown in the bar.

(open: boolean) => void—
disabled

Disables the group button.

booleanfalse

Also accepts native <li> attributes, plus className, style and ref.

Navbar.Actions

Navbar.Actions props
PropTypeDefault
children

Buttons, an avatar, a theme toggle, a search field. Stays visible at every width, so keep it short on phones.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Navbar targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves through the brand link, the links and the actions.
EnterSpaceOn the menu button (narrow screens): opens the links in a drawer. On a Navbar.Group button: opens or closes its links.
EscapeCloses the drawer, or an open group's dropdown and returns focus to its button.

The drawer traps focus while open; on close, focus returns to the menu button. A group's dropdown doesn't trap focus: its links stay in the Tab order, and Tab past the last one closes it. Opening one group closes the others.

Roles and states

Roles and states
ElementRoleStates and properties
<header>banner (at the page's top level)—
Navbar.Navnavigationaria-label; links in a list
Active linklinkaria-current="page"
Menu buttonbuttonaria-label, aria-haspopup="dialog", aria-expanded
Navbar.Group buttonbuttonaria-expanded, aria-controls (the open list). A disclosure, not a menu
Link badgenonePart of the link's name ("Messages 3"), or badgeLabel in its place

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)