Zoeken...  ⌘K GitHub

NavTransparent Navigation

Transparante overlay nav over hero. Wordt wit bij scrollen.

/nav-transparent
src/components/nav/NavTransparent.astro
---
/**
 * NavTransparent
 * Transparante overlay nav voor gebruik over hero-afbeeldingen.
 * Wordt wit bij scrollen via JS.
 */
interface Props {
  logo: string;
  links: { label: string; href: string; active?: boolean }[];
  cta?: { label: string; href: string };
  logoLight?: boolean;
}
const { logo, links, cta, logoLight = true } = Astro.props;
---
<header class={`nt${logoLight ? ' nt--light' : ''}`} id="nav-transparent">
  <nav class="nt-inner">
    <a href="/" class="nt-logo">{logo}</a>
    <ul class="nt-links">
      {links.map(l => (
        <li><a href={l.href} class={`nt-link${l.active ? ' nt-link--active' : ''}`}>{l.label}</a></li>
      ))}
    </ul>
    {cta && <a href={cta.href} class="nt-cta">{cta.label}</a>}
  </nav>
</header>
<script>
  const nav = document.getElementById('nav-transparent');
  if (nav) {
    window.addEventListener('scroll', () => {
      nav.classList.toggle('nt--scrolled', window.scrollY > 60);
    }, { passive: true });
  }
</script>
<style>
  .nt { position: fixed; top: 0; left: 0; right: 0; z-index: 100; transition: background 0.3s, box-shadow 0.3s; }
  .nt--scrolled { background: rgba(255,255,255,0.97) !important; box-shadow: 0 1px 12px rgba(0,0,0,0.08); }
  .nt-inner { max-width: 1280px; margin: 0 auto; padding: 0 2rem; display: flex; align-items: center; height: 72px; gap: 2rem; }
  .nt-logo { font-weight: 800; font-size: 1.125rem; text-decoration: none; letter-spacing: -0.02em; transition: color 0.3s; }
  .nt--light .nt-logo { color: #fff; }
  .nt--scrolled .nt-logo { color: #0a0a0a !important; }
  .nt-links { list-style: none; padding: 0; margin: 0; display: flex; flex: 1; gap: 0; }
  .nt-link { display: block; font-size: 0.875rem; font-weight: 500; text-decoration: none; padding: 0.375rem 0.875rem; border-radius: 0.375rem; transition: color 0.15s, background 0.15s; }
  .nt--light .nt-link { color: rgba(255,255,255,0.85); }
  .nt--scrolled .nt-link { color: #374151 !important; }
  .nt-link:hover { background: rgba(99,102,241,0.08); color: var(--color-accent,#6366f1) !important; }
  .nt-cta { margin-left: auto; font-size: 0.875rem; font-weight: 600; padding: 0.5rem 1.25rem; background: var(--color-accent,#6366f1); color: #fff; border-radius: 0.5rem; text-decoration: none; transition: opacity 0.2s; }
  .nt-cta:hover { opacity: 0.88; }
</style>

Props

Prop Type Default Beschrijving
logo * string Merknaam
links * { label: string; href: string; active?: boolean }[] Navigatielinks
cta { label: string; href: string } CTA knop
logoLight boolean true Witte tekst boven dark hero

* = verplicht