Navbar with Dropdown
A nav bar whose Products link opens a real keyboard-navigable submenu - click, arrows, Escape.
6 फ्रेमवर्कएडवांस्ड
A logo, an inline link row and a CTA, collapsing to a hamburger menu below the md breakpoint.
<!--
The links live in a <ul> inside a <nav aria-label="Main"> because a screen
reader user navigating by landmark needs to know which nav this is - a page
with a main nav and a footer nav has two, and "navigation, navigation" is
useless. aria-current="page" marks the active link: without it the highlight
is a colour a screen reader cannot see.
The hamburger is a real <button> with aria-expanded and aria-controls, so its
state is announced rather than implied by an icon rotating.
-->
<header class="navbar">
<nav class="navbar__inner" aria-label="Main">
<a class="navbar__brand" href="/">Adysre</a>
<ul class="navbar__links">
<li><a class="navbar__link" href="/product" aria-current="page">Product</a></li>
<li><a class="navbar__link" href="/pricing">Pricing</a></li>
<li><a class="navbar__link" href="/docs">Docs</a></li>
</ul>
<a class="navbar__cta" href="/signup">Get started</a>
<button
class="navbar__toggle"
type="button"
aria-expanded="false"
aria-controls="navbar-menu"
aria-label="Open main menu"
>
<svg class="navbar__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false">
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</nav>
<ul class="navbar__menu" id="navbar-menu" hidden>
<li><a class="navbar__link" href="/product" aria-current="page">Product</a></li>
<li><a class="navbar__link" href="/pricing">Pricing</a></li>
<li><a class="navbar__link" href="/docs">Docs</a></li>
<li><a class="navbar__cta navbar__cta--block" href="/signup">Get started</a></li>
</ul>
</header>
<script>
document.querySelectorAll('.navbar').forEach(function (root) {
var toggle = root.querySelector('.navbar__toggle');
var menu = root.querySelector('.navbar__menu');
toggle.addEventListener('click', function () {
var open = toggle.getAttribute('aria-expanded') === 'true';
toggle.setAttribute('aria-expanded', String(!open));
toggle.setAttribute('aria-label', open ? 'Open main menu' : 'Close main menu');
menu.hidden = open;
});
});
</script>| Prop | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
ctaLabel | string | 'Get started' | कॉल-टू-एक्शन बटन का टेक्स्ट। |
ctaHref | string | '/signup' | कॉल-टू-एक्शन लिंक का डेस्टिनेशन। |
ariaLabel | string | 'Open main menu' | बटन का एक्सेसिबल नाम। सिर्फ़ आइकन वाले बटन के लिए ज़रूरी है। |
className | string | - | रूट एलिमेंट पर मर्ज होने वाली अतिरिक्त क्लासेज़। |
The active link is marked with `aria-current="page"` and the highlight is styled off that same attribute rather than a parallel `is-active` class - one source of truth, so what a screen reader announces cannot drift from what the eye sees. Drive it from your router: `usePathname() === link.href` in Next.js. The hamburger is a real button with `aria-expanded` and `aria-controls`; the icon swapping from bars to a cross is the *decoration*, those two attributes are what actually communicate state. Change the `md:` breakpoint in one place - the links, the CTA and the toggle all key off it, so moving it means editing three utilities, not one.