Skip to content

Navbar

Responsive top navigation bar. Collapses progressively as viewport shrinks (fullcompactminimalmobile), falling back to an Drawer-based hamburger menu at the mobile stage. Active-item tracking supports route, hash, scroll-spy, or fully manual modes via activeMode.

items accepts either a real array or a JSON string, so it works directly as a plain HTML attribute — no script needed.

<and-navbar
items='[{"id":"home","label":"Home","href":"#"},{"id":"docs","label":"Docs","href":"#"},{"id":"about","label":"About","href":"#"}]'
active-item="home"
></and-navbar>

Properties

PropertyAttributeDescriptionTypeDefault
activeItemactive-itemThe active navigation item ID. Reflects the headless‐core state.string''
activeModeactive-modeStrategy used to compute active item. - auto: prefers scroll-spy when possible, then route, then hash - route: pathname matching (/docs, /demo) - hash: hash matching (#hero) - scroll: scroll-spy based section tracking - manual: external control only (no auto detection)"auto" | "hash" | "manual" | "route" | "scroll"'auto'
ariaNavLabelaria-nav-labelARIA label for the navigationstring'Main navigation'
autoCollapseauto-collapseWhen true, the navbar automatically detects when the nav items overflow and switches to a smaller responsive stage regardless of breakpoints. Content-aware collapse.booleantrue
compactBreakpointcompact-breakpointBreakpoint (px) below which the end section enters compact mode (icon-only, labels hidden). Main nav is still visible.number1024
itemVariantitem-variantVisual style for individual nav links. Controls how each link looks, independent of the navbar container variant. - default — subtle rounded pill with hover bg - underline — bottom-border indicator on active - filled — solid primary bg on active"default" | "filled" | "underline"'default'
itemsitemsNavigation items to display. When provided, the component renders its own items (with full keyboard navigation, scroll-spy, and active‐indicator). When empty, use the nav slot for custom content.NavItem[] | string[]
minimalBreakpointminimal-breakpointBreakpoint (px) below which the main (nav links) section is hidden and the navigation moves to the hamburger drawer. Only start + compact end are visible.number768
mobileBreakpointmobile-breakpointBreakpoint (px) below which the navbar switches to mobile mode (hamburger menu). Set to 0 to always show desktop, or a high value to always show mobile.number640
positionpositionPositioning behaviour"fixed" | "static" | "sticky"'static'
routeMatchModeroute-match-modeRoute matching mode used when activeMode resolves through pathname."exact" | "prefix"'prefix'
scrollSpyscroll-spyEnable scroll-spy (auto-detect active section by scroll position). Items must have href starting with #.booleanfalse
scrollSpyOffsetscroll-spy-offsetScroll-spy offset from the top of viewport (px).number100
variantvariantVisual variant"default" | "filled" | "floating" | "glass"'default'

Events

EventDescriptionType
andMobileMenuChangeEmitted when mobile menu state changesCustomEvent<boolean>
andNavItemClickEmitted when active item changesCustomEvent<string>
andNavLinkClickEmitted when a navigation link is clickedCustomEvent<{ id: string; href: string; }>
andResponsiveStageChangeEmitted when responsive stage changesCustomEvent<"compact" | "full" | "minimal" | "mobile">
Generated from packages/web-components/src/components/and-navbar/readme.md — keep this in sync with the Stencil source, don't hand-edit the numbers.