Floating Pill Navigation

This navigation bar uses floating pill items with motion feedback to indicate active and hover states in compact layouts.

HTML

<nav class="nav-pill">
  <a class="is-active">Home</a>
  <a>Docs</a>
  <a>API</a>
</nav>

CSS

.nav-pill {
  width: 200px;
  padding: 0.4rem;
  border-radius: 999px;
  background: #f3f4f6;
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
}

.nav-pill a {
  flex: 1;
  text-align: center;
  padding: 0.35rem 0;
  border-radius: 999px;
  font-size: 12px;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  transition: background 200ms ease, transform 150ms ease;
}

.nav-pill a:hover {
  background: rgba(99,102,241,0.15);
  transform: translateY(-1px);
}

.nav-pill a.is-active {
  background: #6366f1;
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .nav-pill {
    background: #111827;
  }

  .nav-pill a {
    color: #e5e7eb;
  }

  .nav-pill a.is-active {
    background: #818cf8;
    color: #020617;
  }
}

Notes

  • Motion-based hover feedback
  • Clear active state
  • Ideal for compact dashboards

Preview styles shown. Production customization recommended.

Browse More UI Components

Explore hundreds of reusable HTML & CSS UI components built for modern web projects.
Discover buttons, cards, loaders, animations, layouts, and more all with live previews and clean, copy-paste code.

Leave a Reply

Your email address will not be published. Required fields are marked *