Skip to content

Underline Nav

A copy-paste navigation component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

NavigationHTMLCSSany framework

Copy into your project

HTML
<nav class="nuda-underline-nav" aria-label="Main navigation">
  <a class="nuda-underline-nav__link active" href="#" aria-current="page">Home</a>
  <a class="nuda-underline-nav__link" href="#">About</a>
  <a class="nuda-underline-nav__link" href="#">Work</a>
  <a class="nuda-underline-nav__link" href="#">Contact</a>
</nav>
CSS
/* Underline Nav
   Nav links with sliding underline indicator.
   Customize: --nav-accent, --nav-text, --nav-text-hover */

.nuda-underline-nav {
  --nav-accent: #e4ff54;
  --nav-text: #999;
  --nav-text-hover: #fff;
  display: flex;
  gap: 2rem;
  position: relative;
  padding-bottom: 2px;
}

.nuda-underline-nav__link {
  color: var(--nav-text);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem 0;
  position: relative;
  transition: color 0.3s ease;
}

.nuda-underline-nav__link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--nav-accent);
  transform: scaleX(0);
  transition: transform 0.3s ease;
  transform-origin: left;
}

.nuda-underline-nav__link:hover {
  color: var(--nav-text-hover);
}

.nuda-underline-nav__link:hover::after,
.nuda-underline-nav__link.active::after {
  transform: scaleX(1);
}

.nuda-underline-nav__link.active {
  color: var(--nav-text-hover);
}

@media (prefers-reduced-motion: reduce) {
  .nuda-underline-nav__link::after {
    transition: none;
  }
  .nuda-underline-nav__link {
    transition: none;
  }
}

How to use Underline Nav

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More navigation components

← Browse all NudaUI components