Zoeken...  ⌘K GitHub

NavColorful Navigation

Kleurrijke pill-labels per categorie. Ideaal voor portals.

/nav-colorful
src/components/nav/NavColorful.astro
---
/**
 * NavColorful
 * Kleurrijke navigatie met gekleurde categorielabels. Ideaal voor portals.
 */
interface Props {
  logo: string;
  links: { label: string; href: string; color?: string; active?: boolean }[];
  cta?: { label: string; href: string };
}
const { logo, links, cta } = Astro.props;
const defaultColors = ['#6366f1','#10b981','#f59e0b','#ef4444','#3b82f6','#8b5cf6','#14b8a6'];
---
<header class="ncl">
  <nav class="ncl-inner">
    <a href="/" class="ncl-logo">{logo}</a>
    <ul class="ncl-links">
      {links.map((l, i) => {
        const c = l.color ?? defaultColors[i % defaultColors.length];
        return (
          <li>
            <a href={l.href} class={`ncl-link${l.active ? ' ncl-link--active' : ''}`} style={`--lc:${c}`}>
              {l.label}
            </a>
          </li>
        );
      })}
    </ul>
    {cta && <a href={cta.href} class="ncl-cta">{cta.label}</a>}
  </nav>
</header>
<style>
  .ncl { background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 100; }
  .ncl-inner { max-width: 1280px; margin: 0 auto; padding: 0 2rem; display: flex; align-items: center; height: 64px; gap: 2rem; }
  .ncl-logo { font-weight: 800; font-size: 1.0625rem; color: #0a0a0a; text-decoration: none; letter-spacing: -0.02em; }
  .ncl-links { list-style: none; padding: 0; margin: 0; display: flex; flex: 1; gap: 0.25rem; }
  .ncl-link { display: block; font-size: 0.8125rem; font-weight: 600; text-decoration: none; padding: 0.325rem 0.75rem; border-radius: 999px; background: color-mix(in srgb, var(--lc) 10%, transparent); color: var(--lc); transition: all 0.15s; }
  .ncl-link:hover, .ncl-link--active { background: color-mix(in srgb, var(--lc) 20%, transparent); }
  .ncl-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; }
  .ncl-cta:hover { opacity: 0.88; }
  @media (max-width: 768px) { .ncl-links { display: none; } }
</style>

Props

Prop Type Default Beschrijving
logo * string Merknaam
links * { label: string; href: string; color?: string; active?: boolean }[] Links met optionele eigen kleur
cta { label: string; href: string } CTA knop

* = verplicht