Zoeken...  ⌘K GitHub

NavIconLinks Navigation

Navigatie met icon + label. Geschikt voor app-interfaces.

/nav-icon-links
src/components/nav/NavIconLinks.astro
---
/**
 * NavIconLinks
 * Navigatie met icon + label combinatie per link. Geschikt voor apps.
 */
interface Props {
  logo: string;
  links: { label: string; href: string; icon: string; active?: boolean }[];
  userMenu?: { name: string; avatar?: string };
  cta?: { label: string; href: string };
}
const { logo, links, userMenu, cta } = Astro.props;
---
<header class="nil">
  <nav class="nil-inner">
    <a href="/" class="nil-logo">{logo}</a>
    <ul class="nil-links">
      {links.map(l => (
        <li>
          <a href={l.href} class={`nil-link${l.active ? ' nil-link--active' : ''}`}>
            <span class="nil-icon">{l.icon}</span>
            <span class="nil-label">{l.label}</span>
          </a>
        </li>
      ))}
    </ul>
    <div class="nil-right">
      {cta && <a href={cta.href} class="nil-cta">{cta.label}</a>}
      {userMenu && (
        <div class="nil-user">
          {userMenu.avatar
            ? <img src={userMenu.avatar} alt={userMenu.name} class="nil-avatar" />
            : <div class="nil-avatar-fallback">{userMenu.name.charAt(0)}</div>
          }
        </div>
      )}
    </div>
  </nav>
</header>
<style>
  .nil { background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 100; }
  .nil-inner { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; display: flex; align-items: center; height: 60px; gap: 1.5rem; }
  .nil-logo { font-weight: 800; font-size: 1rem; color: #0a0a0a; text-decoration: none; letter-spacing: -0.02em; }
  .nil-links { list-style: none; padding: 0; margin: 0; display: flex; flex: 1; gap: 0; }
  .nil-link { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; font-weight: 500; color: #6b7280; text-decoration: none; padding: 0.375rem 0.75rem; border-radius: 0.375rem; transition: all 0.15s; }
  .nil-link:hover { color: #374151; background: #f8fafc; }
  .nil-link--active { color: var(--color-accent,#6366f1); background: rgba(99,102,241,0.08); }
  .nil-icon { font-size: 1rem; flex-shrink: 0; }
  .nil-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
  .nil-cta { font-size: 0.8125rem; font-weight: 600; padding: 0.4375rem 1rem; background: var(--color-accent,#6366f1); color: #fff; border-radius: 0.5rem; text-decoration: none; transition: opacity 0.2s; }
  .nil-cta:hover { opacity: 0.88; }
  .nil-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
  .nil-avatar-fallback { width: 32px; height: 32px; border-radius: 50%; background: var(--color-accent,#6366f1); color: #fff; font-size: 0.875rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
  @media (max-width: 640px) { .nil-label { display: none; } }
</style>

Props

Prop Type Default Beschrijving
logo * string Merknaam
links * { label: string; href: string; icon: string; active?: boolean }[] Links met emoji icon
cta { label: string; href: string } CTA knop
userMenu { name: string; avatar?: string } Gebruikersmenu rechtsboven

* = verplicht