NavWithSearch Navigation
Navigatie met ingebouwde zoekbalk. Voor kennisbanken en shops.
src/components/nav/NavWithSearch.astro
---
/**
* NavWithSearch
* Navigatie met zoekbalk. Geschikt voor kennisbanken, shops en portals.
*/
interface Props {
logo: string;
links: { label: string; href: string; active?: boolean }[];
searchPlaceholder?: string;
cta?: { label: string; href: string };
}
const { logo, links, searchPlaceholder = 'Zoeken...', cta } = Astro.props;
---
<header class="nws">
<nav class="nws-inner">
<a href="/" class="nws-logo">{logo}</a>
<ul class="nws-links">
{links.map(l => (
<li><a href={l.href} class={`nws-link${l.active ? ' nws-link--active' : ''}`}>{l.label}</a></li>
))}
</ul>
<div class="nws-search">
<svg class="nws-search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>
<input type="search" placeholder={searchPlaceholder} class="nws-input" />
</div>
{cta && <a href={cta.href} class="nws-cta">{cta.label}</a>}
</nav>
</header>
<style>
.nws { background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 100; }
.nws-inner { max-width: 1280px; margin: 0 auto; padding: 0 2rem; display: flex; align-items: center; height: 64px; gap: 1.5rem; }
.nws-logo { font-weight: 800; font-size: 1.0625rem; color: #0a0a0a; text-decoration: none; letter-spacing: -0.02em; white-space: nowrap; }
.nws-links { list-style: none; padding: 0; margin: 0; display: flex; gap: 0; }
.nws-link { display: block; font-size: 0.875rem; font-weight: 500; color: #374151; text-decoration: none; padding: 0.375rem 0.75rem; border-radius: 0.375rem; transition: all 0.15s; white-space: nowrap; }
.nws-link:hover, .nws-link--active { color: var(--color-accent,#6366f1); background: rgba(99,102,241,0.07); }
.nws-search { flex: 1; max-width: 280px; position: relative; margin-left: auto; }
.nws-search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.nws-input { width: 100%; padding: 0.5rem 0.75rem 0.5rem 2.25rem; font-size: 0.875rem; border: 1px solid #e5e7eb; border-radius: 0.5rem; outline: none; background: #f9fafb; transition: border-color 0.15s; }
.nws-input:focus { border-color: var(--color-accent,#6366f1); background: #fff; }
.nws-cta { font-size: 0.875rem; font-weight: 600; padding: 0.5rem 1.125rem; background: var(--color-accent,#6366f1); color: #fff; border-radius: 0.5rem; text-decoration: none; transition: opacity 0.2s; white-space: nowrap; }
.nws-cta:hover { opacity: 0.88; }
@media (max-width: 768px) { .nws-links { display: none; } .nws-search { max-width: 160px; } }
</style>
Props
| Prop | Type | Default | Beschrijving |
|---|---|---|---|
logo * | string | — | Merknaam |
links * | { label: string; href: string; active?: boolean }[] | — | Navigatielinks |
searchPlaceholder | string | — | Placeholder voor zoekbalk |
cta | { label: string; href: string } | — | CTA knop |
* = verplicht