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:
import { JNavbar, JNavbarLink } from '@juxtui/ui'Usage #
<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
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | false | Mobile 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. |
| sticky | boolean | true | Stick to the top of the viewport while scrolling. |
| bordered | boolean | true | Hairline under the bar. |
| maxWidth | string | '72rem' | Maximum content width, or none for full width. |
| label | string | 'Main' | Accessible name of the navigation landmark. |
Slots
| Slot | Props | 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
| Prop | Type | Default | Description |
|---|---|---|---|
| active | boolean | false | Marks the current page (aria-current="page"). |
| as | string | Component | 'a' | Render as NuxtLink, RouterLink or any element. |
Slots
| Slot | Props | Description |
|---|---|---|
| default | — | Label. |
| leading | — | Icon. |
Accessibility #
- Renders a
<header>containing a<nav>landmark named bylabel. - The burger exposes
aria-expandedandaria-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 |
|---|---|
| Tab | Moves through brand, links, actions and the burger in reading order. |
| Enter | On the burger: opens the menu and focuses its first link. |
| Esc | Closes the mobile menu and returns focus to the burger. |