Layout

Navbar

The top bar of a site or app: brand, links and actions. Below a breakpoint the links fold behind a burger into a menu that drops from the bar.

Installation #

With the Nuxt module, every component is auto-imported — there is nothing to add. In a plain Vue project, import what you use:

Copy
import { JNavbar, JNavbarLink } from '@juxtui/ui'

Usage #

Copy
<JNavbar>
  <template #brand>
    <NuxtLink to="/">Acme</NuxtLink>
  </template>
  <JNavbarLink :as="NuxtLink" to="/docs" active>Docs</JNavbarLink>
  <JNavbarLink :as="NuxtLink" to="/pricing">Pricing</JNavbarLink>
  <template #actions>
    <JButton size="sm">Sign up</JButton>
  </template>
</JNavbar>

Resize the window below 768px to see the mobile menu. The same links are used in both places, so there is nothing to keep in sync.

The menu closes when a link is chosen, on Escape (focus returns to the burger), on an outside click, and when the window grows past the breakpoint.

Everything in #actions stays visible at every size. Put anything that should only appear in the mobile menu, like a full-width sign-in button, in #menu-footer.

Variants & examples #

In an app#

Links stay inline (collapse="never"), with a dropdown and an avatar menu as actions.

API #

JNavbar

PropTypeDefault Description
openbooleanfalseMobile menu state. Optionally bound with v-model:open.
collapse'sm' | 'md' | 'lg' | 'never''md'Width below which links fold into the mobile menu: 640, 768 or 1024px.
stickybooleantrueStick to the top of the viewport while scrolling.
borderedbooleantrueHairline under the bar.
maxWidthstring'72rem'Maximum content width, or none for full width.
labelstring'Main'Accessible name of the navigation landmark.

Slots

SlotProps Description
brand—Logo or product name, usually a link home.
default—Links, typically JNavbarLinks.
actions—Always visible on the right: search, theme, account.
menu-footer—Only in the mobile menu, below the links.

JNavbarLink

PropTypeDefault Description
activebooleanfalseMarks the current page (aria-current="page").
asstring | Component'a'Render as NuxtLink, RouterLink or any element.

Slots

SlotProps Description
default—Label.
leading—Icon.

Accessibility #

  • Renders a <header> containing a <nav> landmark named by label.
  • The burger exposes aria-expanded and aria-controls, and its accessible name switches between “Open menu” and “Close menu”.
  • The current page is announced with aria-current="page".
  • Links render once per layout; the one not in use is display: none, so assistive technology never sees them twice.

Keyboard #

Key Action
TabMoves through brand, links, actions and the burger in reading order.
EnterOn the burger: opens the menu and focuses its first link.
EscCloses the mobile menu and returns focus to the burger.