1 GitHub star = 1 new component.

Star the repo
Agency & Marketing

Agency Header

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

headernavbaragencymobile-menu

Usage

Copy and paste this code into your React component:

tsx
import { AgencyHeader } from 'react-component-kit-ui/sections';

<AgencyHeader brand="Volta" links={[{ label: 'Services', href: '/services/' }, { label: 'Work', href: '/work/' }]} cta={{ label: 'Free audit', href: '/contact/' }} />

Manual Installation

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

AgencyHeader.tsx
'use client';

import { useEffect, useRef } from 'react';
import './AgencyHeader.css';

/** class:list โ†’ className */
function cx(...args: unknown[]): string {
  const out: string[] = [];
  const walk = (v: unknown) => {
    if (!v) return;
    if (typeof v === 'string' || typeof v === 'number') out.push(String(v));
    else if (Array.isArray(v)) v.forEach(walk);
    else if (typeof v === 'object') for (const [k, on] of Object.entries(v as Record<string, unknown>)) if (on) out.push(k);
  };
  args.forEach(walk);
  return out.join(' ');
}

/**
 * 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.
 */
export interface AgencyHeaderProps {
  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;
}

export function AgencyHeader({
  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 = '',
}: AgencyHeaderProps) {

  // Client-side behaviour: runs once after mount.
  const mounted = useRef(false);
  useEffect(() => {
    if (mounted.current) return;
    mounted.current = true;
    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 });
      });
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

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

export default AgencyHeader;
AgencyHeader.css
.ah:where([data-rk-72bba8]) { position: relative; z-index: 60; padding: 14px clamp(0.75rem, 2vw, 1.5rem); color: var(--c-text-1, #fff); }
.ah--sticky:where([data-rk-72bba8]) { position: sticky; top: 0; }
.ah__bar:where([data-rk-72bba8]) {
  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:where([data-rk-72bba8]) .ah__bar:where([data-rk-72bba8]) { border-radius: 0; border-width: 0 0 1px; max-width: none; }
.ah.is-menu:where([data-rk-72bba8]) .ah__bar:where([data-rk-72bba8]) { backdrop-filter: none; background: transparent; border-color: transparent; box-shadow: none; }
.ah.is-scrolled:where([data-rk-72bba8]) .ah__bar:where([data-rk-72bba8]) { box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.45); }
.ah__brand:where([data-rk-72bba8]) { 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:where([data-rk-72bba8]) { 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:where([data-rk-72bba8]) { margin: 0 auto; }
.ah__nav:where([data-rk-72bba8]) ul:where([data-rk-72bba8]) { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.ah__nav:where([data-rk-72bba8]) a:where([data-rk-72bba8]) { 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:where([data-rk-72bba8]) a:hover:where([data-rk-72bba8]), .ah__nav:where([data-rk-72bba8]) a[aria-current]:where([data-rk-72bba8]) { color: var(--c-text-1, #fff); background: rgb(var(--ink-rgb, 255 255 255) / 0.07); }
.ah__actions:where([data-rk-72bba8]) { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ah__icon:where([data-rk-72bba8]) { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.ah__icon:hover:where([data-rk-72bba8]) { background: rgb(var(--ink-rgb, 255 255 255) / 0.07); }
.ah__cta:where([data-rk-72bba8]) { 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:where([data-rk-72bba8]) { transform: translateY(-1px) rotate(-1deg); color: var(--c-on-primary, #050505); }
.ah__cta--mobile:where([data-rk-72bba8]) { display: none; }
.ah:where([data-rk-72bba8]) :is(a, button):focus-visible:where([data-rk-72bba8]) { outline: 2px solid var(--agency-accent, var(--c-primary-light, #d4a017)); outline-offset: 3px; }
.ah__burger:where([data-rk-72bba8]) { display: none; flex-direction: column; gap: 6px; }
.ah__burger:where([data-rk-72bba8]) span:where([data-rk-72bba8]) { display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; transition: transform 0.25s ease; }
.ah__burger[aria-expanded='true']:where([data-rk-72bba8]) span:first-child:where([data-rk-72bba8]) { transform: translateY(4px) rotate(45deg); }
.ah__burger[aria-expanded='true']:where([data-rk-72bba8]) span:last-child:where([data-rk-72bba8]) { transform: translateY(-4px) rotate(-45deg); }

@media (max-width: 860px) {
  .ah__burger:where([data-rk-72bba8]) { display: grid; place-content: center; }
  .ah__actions:where([data-rk-72bba8]) > .ah__cta:where([data-rk-72bba8]) { display: none; }
  .ah__nav:where([data-rk-72bba8]) {
    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:where([data-rk-72bba8]) { opacity: 1; visibility: visible; }
  .ah__nav:where([data-rk-72bba8]) ul:where([data-rk-72bba8]) { flex-direction: column; gap: 4px; }
  .ah__nav:where([data-rk-72bba8]) a:where([data-rk-72bba8]) { 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__cta--mobile:where([data-rk-72bba8]) { display: inline-flex; align-self: flex-start; font-size: 1rem; min-height: 54px; }
}
@media (prefers-reduced-motion: reduce) { .ah__nav:where([data-rk-72bba8]), .ah__bar:where([data-rk-72bba8]), .ah__cta:where([data-rk-72bba8]), .ah__burger:where([data-rk-72bba8]) span:where([data-rk-72bba8]) { transition: none; } }