Simple Navbar
A logo, an inline link row and a CTA, collapsing to a hamburger menu below the md breakpoint.
6 个框架中级
Links carry an underline that scales in from the centre on hover and stays on the active link.
<!--
Each link carries a bottom underline that scales in from the centre on hover
and stays put on the aria-current link. The scale transition sits behind
motion-reduce, and the underline is a pseudo-element so it never shifts the
text. Below md the strip becomes a plain hamburger list.
-->
<header class="border-b border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
<nav class="mx-auto flex h-14 max-w-6xl items-center gap-4 px-4" aria-label="Main">
<a href="/" class="mr-auto font-bold text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 dark:text-gray-50 dark:focus-visible:ring-blue-400">Adysre</a>
<ul class="hidden items-center gap-6 md:flex">
<li><a href="/product" aria-current="page" class="relative py-4 text-sm font-medium text-gray-900 after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:origin-center after:scale-x-100 after:bg-blue-600 dark:text-gray-50 dark:after:bg-blue-400">Product</a></li>
<li><a href="/pricing" class="relative py-4 text-sm font-medium text-gray-600 transition-colors hover:text-gray-900 after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:origin-center after:scale-x-0 after:bg-blue-600 after:transition-transform hover:after:scale-x-100 motion-reduce:after:transition-none dark:text-gray-400 dark:hover:text-gray-50 dark:after:bg-blue-400">Pricing</a></li>
<li><a href="/docs" class="relative py-4 text-sm font-medium text-gray-600 transition-colors hover:text-gray-900 after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:origin-center after:scale-x-0 after:bg-blue-600 after:transition-transform hover:after:scale-x-100 motion-reduce:after:transition-none dark:text-gray-400 dark:hover:text-gray-50 dark:after:bg-blue-400">Docs</a></li>
</ul>
<a href="/signup" class="ml-2 hidden rounded-lg bg-blue-600 px-3.5 py-1.5 text-sm font-semibold text-white hover:bg-blue-700 md:block">Get started</a>
<button
type="button"
aria-expanded="false"
aria-controls="nav-underline-menu"
aria-label="Open main menu"
class="inline-flex h-9 w-9 items-center justify-center rounded-md text-gray-700 hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 md:hidden dark:text-gray-300 dark:hover:bg-gray-800 dark:focus-visible:ring-blue-400"
>
<svg class="h-5 w-5" 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 id="nav-underline-menu" hidden class="flex flex-col gap-1 border-t border-gray-200 px-4 pb-4 pt-2 md:hidden dark:border-gray-800">
<li><a href="/product" aria-current="page" class="block rounded-md bg-gray-100 px-3 py-2 text-sm font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-50">Product</a></li>
<li><a href="/pricing" class="block rounded-md px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800">Pricing</a></li>
<li><a href="/docs" class="block rounded-md px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800">Docs</a></li>
<li><a href="/signup" class="block rounded-lg bg-blue-600 px-3 py-2 text-center text-sm font-semibold text-white hover:bg-blue-700">Get started</a></li>
</ul>
</header>| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
ctaLabel | string | 'Get started' | 行动号召按钮的文案。 |
ctaHref | string | '/signup' | 行动号召链接的目标地址。 |
className | string | - | 合并到根元素上的额外类名。 |
Each link's underline is an `::after` pseudo-element, so it never nudges the text as it appears, and it scales in from the centre on hover - the transition sits behind `motion-reduce` for anyone who asked for less movement. The active link keeps its underline fixed and is marked with `aria-current`. Below `md` the strip becomes a plain hamburger list.