Navbar
VdNavbar is a responsive top navigation bar with brand, default, and actions slots, a built-in mobile hamburger + slide-in menu, optional dropdowns, and scroll-aware glass/transparent framing. It emits open/close/toggle and exposes imperative open() / close() / toggle() controls.
Live Demo
A real <VdNavbar> (rendered position="static" so it stays inside the card). Narrow the viewport to reveal the hamburger and slide-in menu.
Mobile menu is closed (from the @toggle event).
Dark Theme (dark prop)
Floating glass capsule
This is the docs shell recipe shipped by the package: variant="glass" + float + position="fixed" (or sticky). Transparent at rest; frosted once scrolled. Toggle the site theme — light and dark use the same translucent white frost (dark stays near-transparent so the capsule never reads as grey fog).
Light / dark: scrolled glass always paints rgba(255,255,255,<opacity>) — opacity ~0.42 in light, ~0.08 in dark — plus specular rim. Do not swap in --vd-glass-bg-dark for navbar chrome.
<script setup lang="ts">
import { VdNavbar } from "@vanduo-oss/vd3";
</script>
<template>
<VdNavbar variant="glass" position="fixed" float>
<template #brand>
<a href="/">VD3 UI</a>
</template>
<ul class="vd-navbar-nav">
<li><a class="vd-nav-link active" href="/">Docs</a></li>
<li><a class="vd-nav-link" href="/effects">Effects</a></li>
</ul>
</VdNavbar>
</template><!-- Docs shell pattern — float + glass (package CSS; no site overrides) -->
<nav class="vd-navbar vd-navbar-fixed vd-navbar-float vd-navbar-glass">
<div class="vd-navbar-container">…</div>
</nav>
<!-- Same via VdNavbar -->
<VdNavbar variant="glass" position="fixed" float>
<template #brand>…</template>
<ul class="vd-navbar-nav">…</ul>
</VdNavbar>Usage
Compose the bar with the three named slots. The default slot is the collapsible menu — drop a .vd-navbar-nav list inside it:
<script setup lang="ts">
import { VdNavbar } from "@vanduo-oss/vd3";
</script>
<template>
<VdNavbar position="sticky">
<template #brand>
<a href="/">VD3 UI</a>
</template>
<!-- Default slot: the collapsible menu content -->
<ul class="vd-navbar-nav">
<li><a class="vd-nav-link active" href="/">Home</a></li>
<li><a class="vd-nav-link" href="/docs">Docs</a></li>
<li><a class="vd-nav-link" href="/about">About</a></li>
</ul>
<template #actions>
<button class="vd-btn vd-btn-primary vd-btn-sm">Sign in</button>
</template>
</VdNavbar>
</template>Nested Dropdowns
Wrap a nav item in .vd-navbar-dropdown with a .vd-navbar-dropdown-menu child. Below the collapse breakpoint the parent link toggles the submenu instead of navigating:
<VdNavbar>
<ul class="vd-navbar-nav">
<li><a class="vd-nav-link active" href="/">Home</a></li>
<li class="vd-navbar-dropdown">
<a class="vd-nav-link" href="#">Products</a>
<div class="vd-navbar-dropdown-menu">
<a class="vd-navbar-dropdown-item" href="/app">App</a>
<a class="vd-navbar-dropdown-item" href="/api">API</a>
</div>
</li>
</ul>
</VdNavbar>CSS Variables
| Variable | Default |
|---|---|
--vd-navbar-bg | var(--vd-color-white) |
--vd-navbar-text-color | var(--vd-text-primary) |
--vd-navbar-link-color | var(--vd-text-primary) |
--vd-navbar-link-hover-color | var(--vd-color-primary) |
--vd-navbar-link-active-color | var(--vd-color-primary) |
--vd-navbar-height | 3.4375rem (55px, fib) |
--vd-navbar-padding-x | 1.3125rem (21px, fib) |
--vd-navbar-nav-gap | 1.3125rem (21px, fib) |
--vd-navbar-actions-gap | 2.125rem (34px, fib) |
--vd-navbar-mobile-menu-width | 233px (fib) |
--vd-navbar-float-inset | Responsive fib inset (8 → 13 → 21px by breakpoint) |
--vd-navbar-float-radius | 2.125rem (34px fib capsule) |
--vd-navbar-glass-specular | 0.58 light / 0.38 dark (inset highlight alpha) |
--vd-navbar-glass-elevation | Soft drop shadow under the frosted capsule (theme-tuned in dark) |
API Reference
Props
| Prop | Type | Description |
|---|---|---|
variant | "solid" | "transparent" | "glass" | Surface treatment (default "solid"). glass/transparent gain scroll-activated framing (the .vd-navbar-scrolled class engages once you scroll past the threshold). variant="glass" ships the perfected liquid frost (light + dark — translucent white wash, never grey fog). |
dark | boolean | Applies the dark navbar theme (.vd-navbar-dark). Orthogonal to variant. Default false. Prefer page theme + variant="glass" for frosted chrome; dark is for solid inverse bars. |
position | "static" | "fixed" | "fixed-bottom" | "sticky" | Positioning modifier (default "static"). fixed / fixed-bottom / sticky attach the bar to the viewport. |
float | boolean | Opt-in floating capsule (.vd-navbar-float): Fibonacci inset from the viewport edges + large radius + optical vertical padding. Pair with variant="glass" and position fixed/sticky. Default false (edge-to-edge — back-compat). |
scrollThreshold | number | Scroll distance in px before .vd-navbar-scrolled engages for glass/transparent variants (default: component-resolved). |
toggleLabel | string | Accessible label for the mobile hamburger toggle (default "Toggle navigation"). |
closeOnNavigate | boolean | Close the mobile menu when a non-dropdown nav link is clicked (default true). |
Events
| Event | Payload | Description |
|---|---|---|
open | — | Emitted when the mobile menu opens. |
close | — | Emitted when the mobile menu closes. |
toggle | open: boolean | Emitted on every open/close with the new menu state. |
Slots
| Slot | Description |
|---|---|
brand | Brand / logo area, rendered inside .vd-navbar-brand. Omitted from the DOM when empty. |
default | The collapsible menu content — place your <ul class="vd-navbar-nav"> here. Rendered inside .vd-navbar-menu. |
actions | Trailing CTA area (buttons, theme switcher…), rendered inside .vd-navbar-actions. Omitted when empty. |
Exposed (template ref)
| Member | Description |
|---|---|
isOpen | Reactive boolean reflecting the mobile-menu open state. |
open() | Imperatively open the mobile menu. |
close() | Imperatively close the mobile menu. |
toggle() | Imperatively toggle the mobile menu. |
CSS Classes (slot content)
| Class | Description |
|---|---|
.vd-navbar-nav | List wrapper for a group of navigation links (place in the default slot). |
.vd-nav-link | Individual link within the menu. Append .active for the current route. |
.vd-navbar-dropdown | Wraps a nav item that owns a nested menu; below the breakpoint its link toggles the submenu instead of navigating. |
.vd-navbar-dropdown-menu | Container for the nested dropdown items (add .is-open is handled for you on mobile). |
.vd-navbar-dropdown-item | Individual link inside a dropdown menu. |
.vd-navbar-float | Inset floating capsule for fixed/sticky top bars (Fibonacci margin + large radius + optical padding). Works with .vd-navbar-glass. |
.vd-navbar-glass | Seemore frosted chrome: translucent white wash, saturate blur, inset specular rim (CodePen-inspired). Same frost recipe in light and dark — dark stays near-transparent (no grey fog). Scroll-activated with .vd-navbar-scrolled. |
Composable API (useNavbarGlassScroll)
import { ref } from "vue";
import { useNavbarGlassScroll } from "@vanduo-oss/vd3";
const navbarEl = ref<HTMLElement | null>(null);
// Returns Ref<boolean> (true when window.scrollY exceeds data-scroll-threshold or navbar height)
const isScrolled = useNavbarGlassScroll(navbarEl);| Symbol / Attribute | Description |
|---|---|
useNavbarGlassScroll(navbarRef) | Composable for custom <nav class="vd-navbar vd-navbar-glass"> or .vd-navbar-transparent elements; returns Ref<boolean> indicating whether window.scrollY has passed the scroll threshold. |
data-scroll-threshold | Optional pixel threshold attribute on the navbar element read by useNavbarGlassScroll (falls back to navbar.offsetHeight || 60). |
Accessibility
VdNavbarrenders a semantic<nav>landmark.- The mobile hamburger button sets
:aria-label="toggleLabel"(default"Toggle navigation") and:aria-expanded="isOpen". - Pressing Escape closes open dropdown menus and the mobile navigation drawer.
- Clicking outside the navbar or activating a navigation link (when
closeOnNavigateis true) automatically closes the mobile menu and releases body scroll lock.