1 GitHub star = 1 new component.

Agency & Marketing

Agency Header

Floating pill navigation for agency sites: logo, links, theme toggle, CTA and an animated full-screen mobile menu.

headernavbaragencymobile-menu
Live Preview

Usage

Copy and paste this code into your Astro page:

astro
---
import { AgencyHeader } from 'astro-component-kit/sections';
---

<AgencyHeader brand="Volta" links={[{ label: 'Services', href: '/services/' }, { label: 'Work', href: '/work/' }]} cta={{ label: 'Free audit', href: '/contact/' }} />
--- import { AgencyHeader } from 'astro-component-kit/sections'; --- <AgencyHeader brand="Volta" links={[{ label: 'Services', href: '/services/' }, { label: 'Work', href: '/work/' }]} cta={{ label: 'Free audit', href: '/contact/' }} />

Examples in context

Real code from the kit: how this piece is used inside templates, sections and other components.

Template Marketing Agency AgencyLayout.astro
astro
<AgencyHeader brand={site.name} brandHref={routes.home} links={links} cta={{ label: 'Free audit', href: routes.contact }} currentHref={active || currentHref} />
<AgencyHeader brand={site.name} brandHref={routes.home} links={links} cta={{ label: 'Free audit', href: routes.contact }} currentHref={active || currentHref} />

Used in

Works well with

Manual Installation

If you are not using the npm package, create a new file and paste the following code: src/components/sections/AgencyHeader.astro:

astro
---
/**
 * AgencyHeader — Floating pill navigation for agency and studio sites: logo, links, theme toggle,
 * "Start a project" CTA and an animated full-screen mobile menu.
 *
 * @param {string} brand - Logo text. Default 'Volta'.
 * @param {string} brandHref - Logo link. Default '/'.
 * @param {Array<{label: string, href: string}>} links - Menu links.
 * @param {{label: string, href: string}} cta - Call to action. Default 'Start a project'.
 * @param {string} currentHref - Marks the active link with aria-current.
 * @param {boolean} themeToggle - Show the light/dark toggle. Default true.
 * @param {boolean} sticky - Float over the page while scrolling. Default true.
 * @param {string} variant - Style (pill|bar). Default 'pill'.
 * @param {string} className - Extra class.
 *
 * Accessibility: nav landmark; the mobile menu is a disclosure (aria-expanded) closed with
 * Escape, which returns focus to the toggle; links have 44px targets.
 */
interface Props {
  brand?: string;
  brandHref?: string;
  links?: Array<{ label: string; href: string }>;
  cta?: { label: string; href: string };
  currentHref?: string;
  themeToggle?: boolean;
  sticky?: boolean;
  variant?: 'pill' | 'bar';
  className?: string;
}

const {
  brand = 'Volta',
  brandHref = '/',
  links = [
    { label: 'Work', href: '#work' },
    { label: 'Services', href: '#services' },
    { label: 'Studio', href: '#team' },
    { label: 'Contact', href: '#contact' },
  ],
  cta = { label: 'Start a project', href: '#contact' },
  currentHref,
  themeToggle = true,
  sticky = true,
  variant = 'pill',
  className = '',
} = Astro.props;
---

<header class:list={['ah', `ah--${variant}`, { 'ah--sticky': sticky }, className]} data-agency-header>
  <div class="ah__bar">
    <a class="ah__brand" href={brandHref}><span class="ah__dot" aria-hidden="true"></span>{brand}</a>
    <nav class="ah__nav" id="ah-nav" aria-label="Main" data-nav>
      <ul>
        {links.map((l) => <li><a href={l.href} aria-current={l.href === currentHref ? 'page' : undefined}>{l.label}</a></li>)}
      </ul>
      {cta && <a class="ah__cta ah__cta--mobile" href={cta.href}>{cta.label} <span aria-hidden="true">↗</span></a>}
    </nav>
    <div class="ah__actions">
      {themeToggle && (
        <button class="ah__icon" type="button" aria-label="Switch theme" data-theme-btn>
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="8"/><path d="M12 4a8 8 0 0 1 0 16z" fill="currentColor"/></svg>
        </button>
      )}
      {cta && <a class="ah__cta" href={cta.href}>{cta.label} <span aria-hidden="true">↗</span></a>}
      <button class="ah__icon ah__burger" type="button" aria-expanded="false" aria-controls="ah-nav" aria-label="Menu" data-burger>
        <span aria-hidden="true"></span><span aria-hidden="true"></span>
      </button>
    </div>
  </div>
</header>

<script>
  document.querySelectorAll<HTMLElement>('[data-agency-header]:not([data-bound])').forEach((h) => {
    h.dataset.bound = '';
    const burger = h.querySelector<HTMLButtonElement>('[data-burger]');
    const nav = h.querySelector<HTMLElement>('[data-nav]');
    const set = (open: boolean) => {
      burger?.setAttribute('aria-expanded', String(open));
      nav?.classList.toggle('is-open', open);
      h.classList.toggle('is-menu', open);
      document.documentElement.style.overflow = open ? 'hidden' : '';
    };
    burger?.addEventListener('click', () => set(burger.getAttribute('aria-expanded') !== 'true'));
    nav?.querySelectorAll('a').forEach((a) => a.addEventListener('click', () => set(false)));
    document.addEventListener('keydown', (e) => {
      if (e.key === 'Escape' && burger?.getAttribute('aria-expanded') === 'true') { set(false); burger.focus(); }
    });
    h.querySelector('[data-theme-btn]')?.addEventListener('click', () => {
      const root = document.documentElement;
      const next = root.dataset.theme === 'dark' ? 'light' : 'dark';
      root.dataset.theme = next;
      try { window.localStorage.setItem('ack-theme', next); } catch { /* ignore */ }
    });
    const onScroll = () => h.classList.toggle('is-scrolled', window.scrollY > 12);
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
  });
</script>

<style>
  .ah { position: relative; z-index: 60; padding: 14px clamp(0.75rem, 2vw, 1.5rem); color: var(--c-text-1, #fff); }
  .ah--sticky { position: sticky; top: 0; }
  .ah__bar {
    display: flex;
    align-items: center;
    gap: var(--sp-4, 1rem);
    max-width: 1280px;
    min-height: 60px;
    margin: 0 auto;
    padding: 0 8px 0 22px;
    border-radius: 999px;
    border: 1px solid var(--c-border, rgba(255, 255, 255, 0.1));
    background: rgb(var(--paper-rgb, 5 5 5) / 0.75);
    backdrop-filter: blur(16px) saturate(1.4);
    transition: box-shadow 0.3s ease, background 0.3s ease;
  }
  .ah--bar .ah__bar { border-radius: 0; border-width: 0 0 1px; max-width: none; }
  .ah.is-menu .ah__bar { backdrop-filter: none; background: transparent; border-color: transparent; box-shadow: none; }
  .ah.is-scrolled .ah__bar { box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.45); }
  .ah__brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 900; letter-spacing: -0.05em; color: inherit; text-decoration: none; }
  .ah__dot { width: 14px; height: 14px; border-radius: 50%; background: var(--agency-accent, var(--c-primary-light, #d4a017)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--agency-accent, var(--c-primary-light, #d4a017)) 30%, transparent); }
  .ah__nav { margin: 0 auto; }
  .ah__nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
  .ah__nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: 999px; color: var(--c-text-2, #a3a3a3); font-size: 0.92rem; font-weight: 600; text-decoration: none; transition: background 0.2s ease, color 0.2s ease; }
  .ah__nav a:hover, .ah__nav a[aria-current] { color: var(--c-text-1, #fff); background: rgb(var(--ink-rgb, 255 255 255) / 0.07); }
  .ah__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
  .ah__icon { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
  .ah__icon:hover { background: rgb(var(--ink-rgb, 255 255 255) / 0.07); }
  .ah__cta { display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 1.25rem; border-radius: 999px; background: var(--agency-accent, var(--c-primary-light, #d4a017)); color: var(--c-on-primary, #050505); font-weight: 800; font-size: 0.9rem; text-decoration: none; white-space: nowrap; transition: transform 0.2s ease; }
  .ah__cta:hover { transform: translateY(-1px) rotate(-1deg); color: var(--c-on-primary, #050505); }
  .ah__nav .ah__cta--mobile { display: none; }
  .ah :is(a, button):focus-visible { outline: 2px solid var(--agency-accent, var(--c-primary-light, #d4a017)); outline-offset: 3px; }
  .ah__burger { display: none; flex-direction: column; gap: 6px; }
  .ah__burger span { display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; transition: transform 0.25s ease; }
  .ah__burger[aria-expanded='true'] span:first-child { transform: translateY(4px) rotate(45deg); }
  .ah__burger[aria-expanded='true'] span:last-child { transform: translateY(-4px) rotate(-45deg); }

  @media (max-width: 860px) {
    .ah__burger { display: grid; place-content: center; }
    .ah__actions > .ah__cta { display: none; }
    .ah__nav {
      position: fixed;
      inset: 0;
      z-index: -1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: var(--sp-8, 2rem);
      padding: 100px 28px 40px;
      background: var(--c-bg, #050505);
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .ah__nav.is-open { opacity: 1; visibility: visible; }
    .ah__nav ul { flex-direction: column; gap: 4px; }
    .ah__nav a { min-height: 64px; padding: 0; font-size: clamp(2.2rem, 10vw, 3.2rem); font-weight: 900; letter-spacing: -0.04em; color: var(--c-text-1, #fff); background: none !important; }
    .ah__nav .ah__cta--mobile { display: inline-flex; align-self: flex-start; min-height: 54px; padding: 0 1.4rem; font-size: 1rem; font-weight: 800; letter-spacing: 0; color: var(--c-on-primary, #050505); background: var(--agency-accent, var(--c-primary-light, #d4a017)) !important; }
  }
  @media (prefers-reduced-motion: reduce) { .ah__nav, .ah__bar, .ah__cta, .ah__burger span { transition: none; } }
</style>
--- /** * AgencyHeader — Floating pill navigation for agency and studio sites: logo, links, theme toggle, * "Start a project" CTA and an animated full-screen mobile menu. * * @param {string} brand - Logo text. Default 'Volta'. * @param {string} brandHref - Logo link. Default '/'. * @param {Array<{label: string, href: string}>} links - Menu links. * @param {{label: string, href: string}} cta - Call to action. Default 'Start a project'. * @param {string} currentHref - Marks the active link with aria-current. * @param {boolean} themeToggle - Show the light/dark toggle. Default true. * @param {boolean} sticky - Float over the page while scrolling. Default true. * @param {string} variant - Style (pill|bar). Default 'pill'. * @param {string} className - Extra class. * * Accessibility: nav landmark; the mobile menu is a disclosure (aria-expanded) closed with * Escape, which returns focus to the toggle; links have 44px targets. */ interface Props { brand?: string; brandHref?: string; links?: Array<{ label: string; href: string }>; cta?: { label: string; href: string }; currentHref?: string; themeToggle?: boolean; sticky?: boolean; variant?: 'pill' | 'bar'; className?: string; } const { brand = 'Volta', brandHref = '/', links = [ { label: 'Work', href: '#work' }, { label: 'Services', href: '#services' }, { label: 'Studio', href: '#team' }, { label: 'Contact', href: '#contact' }, ], cta = { label: 'Start a project', href: '#contact' }, currentHref, themeToggle = true, sticky = true, variant = 'pill', className = '', } = Astro.props; --- <header class:list={['ah', `ah--${variant}`, { 'ah--sticky': sticky }, className]} data-agency-header> <div class="ah__bar"> <a class="ah__brand" href={brandHref}><span class="ah__dot" aria-hidden="true"></span>{brand}</a> <nav class="ah__nav" id="ah-nav" aria-label="Main" data-nav> <ul> {links.map((l) => <li><a href={l.href} aria-current={l.href === currentHref ? 'page' : undefined}>{l.label}</a></li>)} </ul> {cta && <a class="ah__cta ah__cta--mobile" href={cta.href}>{cta.label} <span aria-hidden="true">↗</span></a>} </nav> <div class="ah__actions"> {themeToggle && ( <button class="ah__icon" type="button" aria-label="Switch theme" data-theme-btn> <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="8"/><path d="M12 4a8 8 0 0 1 0 16z" fill="currentColor"/></svg> </button> )} {cta && <a class="ah__cta" href={cta.href}>{cta.label} <span aria-hidden="true">↗</span></a>} <button class="ah__icon ah__burger" type="button" aria-expanded="false" aria-controls="ah-nav" aria-label="Menu" data-burger> <span aria-hidden="true"></span><span aria-hidden="true"></span> </button> </div> </div> </header> <script> document.querySelectorAll<HTMLElement>('[data-agency-header]:not([data-bound])').forEach((h) => { h.dataset.bound = ''; const burger = h.querySelector<HTMLButtonElement>('[data-burger]'); const nav = h.querySelector<HTMLElement>('[data-nav]'); const set = (open: boolean) => { burger?.setAttribute('aria-expanded', String(open)); nav?.classList.toggle('is-open', open); h.classList.toggle('is-menu', open); document.documentElement.style.overflow = open ? 'hidden' : ''; }; burger?.addEventListener('click', () => set(burger.getAttribute('aria-expanded') !== 'true')); nav?.querySelectorAll('a').forEach((a) => a.addEventListener('click', () => set(false))); document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && burger?.getAttribute('aria-expanded') === 'true') { set(false); burger.focus(); } }); h.querySelector('[data-theme-btn]')?.addEventListener('click', () => { const root = document.documentElement; const next = root.dataset.theme === 'dark' ? 'light' : 'dark'; root.dataset.theme = next; try { window.localStorage.setItem('ack-theme', next); } catch { /* ignore */ } }); const onScroll = () => h.classList.toggle('is-scrolled', window.scrollY > 12); onScroll(); window.addEventListener('scroll', onScroll, { passive: true }); }); </script> <style> .ah { position: relative; z-index: 60; padding: 14px clamp(0.75rem, 2vw, 1.5rem); color: var(--c-text-1, #fff); } .ah--sticky { position: sticky; top: 0; } .ah__bar { display: flex; align-items: center; gap: var(--sp-4, 1rem); max-width: 1280px; min-height: 60px; margin: 0 auto; padding: 0 8px 0 22px; border-radius: 999px; border: 1px solid var(--c-border, rgba(255, 255, 255, 0.1)); background: rgb(var(--paper-rgb, 5 5 5) / 0.75); backdrop-filter: blur(16px) saturate(1.4); transition: box-shadow 0.3s ease, background 0.3s ease; } .ah--bar .ah__bar { border-radius: 0; border-width: 0 0 1px; max-width: none; } .ah.is-menu .ah__bar { backdrop-filter: none; background: transparent; border-color: transparent; box-shadow: none; } .ah.is-scrolled .ah__bar { box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.45); } .ah__brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 900; letter-spacing: -0.05em; color: inherit; text-decoration: none; } .ah__dot { width: 14px; height: 14px; border-radius: 50%; background: var(--agency-accent, var(--c-primary-light, #d4a017)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--agency-accent, var(--c-primary-light, #d4a017)) 30%, transparent); } .ah__nav { margin: 0 auto; } .ah__nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; } .ah__nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: 999px; color: var(--c-text-2, #a3a3a3); font-size: 0.92rem; font-weight: 600; text-decoration: none; transition: background 0.2s ease, color 0.2s ease; } .ah__nav a:hover, .ah__nav a[aria-current] { color: var(--c-text-1, #fff); background: rgb(var(--ink-rgb, 255 255 255) / 0.07); } .ah__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; } .ah__icon { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; } .ah__icon:hover { background: rgb(var(--ink-rgb, 255 255 255) / 0.07); } .ah__cta { display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 1.25rem; border-radius: 999px; background: var(--agency-accent, var(--c-primary-light, #d4a017)); color: var(--c-on-primary, #050505); font-weight: 800; font-size: 0.9rem; text-decoration: none; white-space: nowrap; transition: transform 0.2s ease; } .ah__cta:hover { transform: translateY(-1px) rotate(-1deg); color: var(--c-on-primary, #050505); } .ah__nav .ah__cta--mobile { display: none; } .ah :is(a, button):focus-visible { outline: 2px solid var(--agency-accent, var(--c-primary-light, #d4a017)); outline-offset: 3px; } .ah__burger { display: none; flex-direction: column; gap: 6px; } .ah__burger span { display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; transition: transform 0.25s ease; } .ah__burger[aria-expanded='true'] span:first-child { transform: translateY(4px) rotate(45deg); } .ah__burger[aria-expanded='true'] span:last-child { transform: translateY(-4px) rotate(-45deg); } @media (max-width: 860px) { .ah__burger { display: grid; place-content: center; } .ah__actions > .ah__cta { display: none; } .ah__nav { position: fixed; inset: 0; z-index: -1; display: flex; flex-direction: column; justify-content: center; gap: var(--sp-8, 2rem); padding: 100px 28px 40px; background: var(--c-bg, #050505); opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; } .ah__nav.is-open { opacity: 1; visibility: visible; } .ah__nav ul { flex-direction: column; gap: 4px; } .ah__nav a { min-height: 64px; padding: 0; font-size: clamp(2.2rem, 10vw, 3.2rem); font-weight: 900; letter-spacing: -0.04em; color: var(--c-text-1, #fff); background: none !important; } .ah__nav .ah__cta--mobile { display: inline-flex; align-self: flex-start; min-height: 54px; padding: 0 1.4rem; font-size: 1rem; font-weight: 800; letter-spacing: 0; color: var(--c-on-primary, #050505); background: var(--agency-accent, var(--c-primary-light, #d4a017)) !important; } } @media (prefers-reduced-motion: reduce) { .ah__nav, .ah__bar, .ah__cta, .ah__burger span { transition: none; } } </style>
Part of a complete template

This section was crafted as a core block for the following template. You can preview the full interactive multi-page experience or explore all related components.

Full templates 8 pages · 20 components

Marketing Agency

A complete website for a performance marketing agency selling Paid Ads, SEO and web development.

More Sections to Explore

Discover other full-width landing blocks and production-ready sections from our library.

All sections