src/components/nav/NavAnimated.astro
---
/**
* NavAnimated
* Navigatie met geanimeerde sliding-underline indicator. CSS-only.
*/
interface Props {
logo: string;
links: { label: string; href: string; active?: boolean }[];
cta?: { label: string; href: string };
}
const { logo, links, cta } = Astro.props;
---
<header class="na">
<nav class="na-inner">
<a href="/" class="na-logo">{logo}</a>
<ul class="na-links">
{links.map(l => (
<li class="na-item">
<a href={l.href} class={`na-link${l.active ? ' na-link--active' : ''}`}>{l.label}</a>
</li>
))}
</ul>
{cta && <a href={cta.href} class="na-cta">{cta.label}</a>}
</nav>
</header>
<style>
.na { background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 100; }
.na-inner { max-width: 1280px; margin: 0 auto; padding: 0 2rem; display: flex; align-items: center; height: 64px; gap: 2rem; }
.na-logo { font-weight: 800; font-size: 1.0625rem; color: #0a0a0a; text-decoration: none; letter-spacing: -0.02em; }
.na-links { list-style: none; padding: 0; margin: 0; display: flex; flex: 1; gap: 0; }
.na-item { position: relative; }
.na-link { display: block; font-size: 0.875rem; font-weight: 500; color: #6b7280; text-decoration: none; padding: 0.375rem 0.875rem; transition: color 0.2s; }
.na-link::after { content: ''; position: absolute; bottom: -1px; left: 0.875rem; right: 0.875rem; height: 2px; background: var(--color-accent,#6366f1); transform: scaleX(0); transform-origin: left; transition: transform 0.25s cubic-bezier(0.4,0,0.2,1); border-radius: 2px; }
.na-link:hover { color: #0a0a0a; }
.na-link:hover::after, .na-link--active::after { transform: scaleX(1); }
.na-link--active { color: var(--color-accent,#6366f1); }
.na-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; white-space: nowrap; }
.na-cta:hover { opacity: 0.88; }
@media (max-width: 768px) { .na-links { display: none; } }
</style>
Props
| Prop | Type | Default | Beschrijving |
|---|---|---|---|
logo * | string | — | Merknaam |
links * | { label: string; href: string; active?: boolean }[] | — | Navigatielinks |
cta | { label: string; href: string } | — | CTA knop |
* = verplicht