kitbash Sign in Connect agent
Components

Night globe hero

The top bar with wordmark, mono menu and white pill, over a black field with a turning dotted globe, glowing route arcs and a blue rim, plus the wide caps headline and two pills.

Part of the style

Black Road White Page

7 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #fbf4ee;
  --ink-mid: rgba(251, 244, 238, 0.72);
  --ink-soft: rgba(251, 244, 238, 0.4);
  --paper: #251a1a;
  --night: #110c08;
  --panel: #fbf4ee;
  --on-night: #251a1a;
  --on-night-soft: rgba(37, 26, 26, 0.6);
  --on-night-faint: rgba(37, 26, 26, 0.24);
  --ghost: #312626;
  --lane: #342828;
  --line-light: rgba(251, 244, 238, 0.14);
  --line-dark: rgba(37, 26, 26, 0.14);
  --signal: #a07b75;
  --signal-light: #8c7672;
  --rim: #8c6b65;
  --route: #87645e;
}
</style>

<section class="hero">
  <canvas class="hero__globe" role="img" aria-label="A dotted globe turning slowly, with orange route arcs rising between stops"></canvas>

  <p class="hero__news"><span class="hero__news-label">Notice:</span> Winter timetable from 1 December. Night coaches add two stops on the Danube line.</p>

  <header class="hero__bar">
    <a class="hero__mark" href="#"><svg class="hero__glyph" viewBox="0 0 24 24" aria-hidden="true"><circle cx="4" cy="18" r="3"/><circle cx="20" cy="6" r="3"/><path d="M4 18 C 6 6, 14 4, 20 6" fill="none" stroke-width="2"/></svg><span class="hero__name">Merrow Overland</span></a>
    <button class="hero__toggle" type="button" aria-expanded="false" aria-controls="hero-menu">Menu</button>
    <nav class="hero__menu" id="hero-menu" aria-label="Main">
      <a class="hero__link" href="#">Routes</a>
      <a class="hero__link" href="#">Timetables</a>
      <a class="hero__link" href="#">Charter</a>
      <a class="hero__link" href="#">Journal</a>
      <a class="hero__link" href="#">Careers</a>
      <a class="hero__link" href="#">Contact</a>
    </nav>
    <a class="hero__pill hero__pill--white hero__book" href="#">Book a seat</a>
  </header>

  <div class="hero__copy">
    <p class="hero__kicker">One ticket</p>
    <h1 class="hero__title">Every road across the continent</h1>
    <p class="hero__lead">Night coaches, day express and charter, from the Atlantic coast to the Silk Road, run by one crew that answers the phone.</p>
    <div class="hero__actions">
      <a class="hero__pill hero__pill--white" href="#">Plan a trip</a>
      <a class="hero__pill" href="#">Our routes</a>
    </div>
  </div>
</section>

<style>
  .hero {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr;
    min-height: clamp(640px, 62vw, 900px);
    background: var(--night);
    color: var(--on-night);
    overflow: hidden;
    isolation: isolate;
  }
  .hero__globe {
    position: absolute;
    z-index: -1;
    top: -12%;
    right: -18%;
    width: min(1100px, 92%);
    aspect-ratio: 1;
  }
  .hero__news {
    margin: 0;
    padding: var(--space-s) var(--edge);
    font-family: var(--font-mono);
    font-size: 8.5px;
    line-height: 1.4;
    text-transform: uppercase;
    color: var(--on-night-soft);
  }
  .hero__news-label { color: var(--on-night); }
  .hero__bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: var(--gap);
    padding: var(--space-m) var(--edge);
  }
  .hero__mark {
    display: inline-flex;
    align-items: center;
    gap: var(--space-s);
    min-height: var(--tap);
    color: inherit;
    text-decoration: none;
    font-family: var(--font-display);
    font-variation-settings: "wdth" var(--display-width);
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
  }
  .hero__glyph {
    width: 18px;
    height: 18px;
    fill: var(--signal);
    stroke: var(--on-night);
  }
  .hero__toggle,
  .hero__pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 var(--space-m);
    border: var(--rule) solid var(--on-night-faint);
    border-radius: var(--pill);
    background: transparent;
    color: var(--on-night);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--mid) var(--ease), color var(--mid) var(--ease), border-color var(--mid) var(--ease);
  }
  .hero__pill:hover,
  .hero__toggle:hover,
  .hero__pill:focus-visible,
  .hero__toggle:focus-visible {
    background: var(--on-night);
    border-color: var(--on-night);
    color: var(--ink);
    outline: none;
  }
  .hero__pill--white {
    background: var(--on-night);
    border-color: var(--on-night);
    color: var(--ink);
  }
  .hero__pill--white:hover,
  .hero__pill--white:focus-visible {
    background: var(--signal);
    border-color: var(--signal);
    color: var(--on-night);
  }
  .hero__menu {
    grid-column: 1 / -1;
    display: none;
    flex-direction: column;
    padding: var(--space-s) 0 var(--space-m);
    border-top: var(--rule) solid var(--line-dark);
  }
  .hero.is-open .hero__menu { display: flex; }
  .hero__link {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    color: var(--on-night);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    text-decoration: none;
    transition: color var(--quick) var(--ease);
  }
  .hero__link:hover,
  .hero__link:focus-visible { color: var(--signal-light); outline: none; }
  .hero__book { display: none; }

  .hero__copy {
    align-self: end;
    display: grid;
    gap: var(--space-m);
    justify-items: start;
    padding: var(--space-xl) var(--edge) var(--space-xl);
    max-width: 640px;
  }
  .hero__kicker {
    margin: 0;
    font-family: var(--font-display);
    font-variation-settings: "wdth" var(--display-width);
    font-size: var(--text-s);
    font-weight: 600;
    text-transform: uppercase;
  }
  .hero__title {
    margin: 0;
    font-family: var(--font-display);
    font-variation-settings: "wdth" var(--display-width);
    font-size: var(--display-l);
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    text-wrap: balance;
  }
  .hero__lead {
    max-width: 30ch;
    margin: 0;
    font-size: var(--text-s);
    line-height: 1.35;
    color: var(--on-night-soft);
  }
  .hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
    padding-top: var(--space-m);
  }

  @media (min-width: 760px) {
    .hero__bar {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    }
    .hero__toggle { display: none; }
    .hero__menu {
      grid-column: auto;
      display: flex;
      padding: 0;
      border: 0;
    }
    .hero__menu { padding-block: 11px; }
    .hero__link { margin-block: -11px; }
    .hero__book { display: inline-flex; }
    .hero__copy {
      padding-left: calc(var(--edge) + (100% - 2 * var(--edge)) / 4);
      max-width: none;
    }
    .hero__lead { max-width: 34ch; }
    .hero__title { max-width: 9.5em; }
  }
  @media (max-width: 759px) {
    .hero__globe {
      top: 18%;
      right: -40%;
      width: 130%;
    }
  }
</style>

<script>
(() => {
  const LAND = [
    [[-168,66],[-140,70],[-95,72],[-80,63],[-62,58],[-55,50],[-66,44],[-76,35],[-81,25],[-97,26],[-97,20],[-87,15],[-78,8],[-85,10],[-105,20],[-117,32],[-124,40],[-124,48],[-135,58],[-150,60],[-165,60]],
    [[-50,60],[-20,70],[-20,82],[-60,82],[-70,76],[-55,70]],
    [[-78,8],[-60,10],[-50,0],[-35,-6],[-40,-22],[-48,-28],[-58,-38],[-66,-55],[-73,-50],[-72,-30],[-71,-18],[-81,-5],[-80,2]],
    [[-10,36],[-9,44],[-2,44],[-5,48],[2,51],[8,54],[8,57],[5,62],[15,69],[28,71],[40,67],[40,46],[28,41],[23,36],[12,38],[3,43]],
    [[-6,50],[2,51],[-2,56],[-5,58],[-6,55]],
    [[-17,15],[-17,21],[-10,30],[-6,36],[10,37],[32,31],[35,28],[43,12],[51,12],[40,-5],[40,-15],[35,-25],[20,-35],[17,-29],[12,-17],[13,-5],[9,4],[-8,5]],
    [[44,-13],[50,-15],[47,-25],[44,-22]],
    [[28,41],[40,46],[40,67],[60,70],[80,73],[110,77],[140,72],[180,68],[170,60],[160,55],[142,46],[135,35],[122,30],[120,22],[108,20],[106,10],[100,13],[98,8],[92,22],[80,15],[77,8],[72,21],[60,25],[57,23],[52,16],[43,12],[35,28],[36,36]],
    [[95,5],[105,-6],[120,-9],[140,-8],[150,-6],[140,-2],[120,1],[117,7],[110,2],[100,2]],
    [[130,31],[141,36],[142,45],[139,40]],
    [[114,-22],[122,-18],[130,-12],[137,-12],[142,-11],[146,-19],[153,-28],[150,-37],[140,-38],[132,-32],[116,-35],[114,-26]],
    [[172,-34],[178,-38],[174,-41],[167,-46],[171,-44]]
  ];
  const ROUTES = [[[-9,39],[16,48]],[[5,43],[29,41]],[[20,50],[45,42]],[[29,41],[67,40]],[[-6,37],[9,45]],[[16,48],[37,56]]];
  const inside = (x, y, ring) => {
    let hit = false;
    for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
      const [xi, yi] = ring[i], [xj, yj] = ring[j];
      if ((yi > y) !== (yj > y) && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) hit = !hit;
    }
    return hit;
  };
  const RAD = Math.PI / 180;
  const vec = ([lon, lat]) => [Math.cos(lat * RAD) * Math.sin(lon * RAD), Math.sin(lat * RAD), Math.cos(lat * RAD) * Math.cos(lon * RAD)];
  const dots = [];
  for (let lat = -80; lat <= 82; lat += 2.2) {
    const step = 2.2 / Math.max(0.2, Math.cos(lat * RAD));
    for (let lon = -180; lon < 180; lon += step) {
      if (LAND.some((ring) => inside(lon, lat, ring))) dots.push(vec([lon, lat]));
    }
  }
  const still = matchMedia('(prefers-reduced-motion: reduce)');

  function setup(root) {
    const canvas = root.querySelector('.hero__globe');
    const context = canvas.getContext('2d');
    const css = getComputedStyle(root);
    const white = css.getPropertyValue('--on-night').trim();
    const route = css.getPropertyValue('--route').trim();
    const rim = css.getPropertyValue('--rim').trim();
    const night = css.getPropertyValue('--night').trim();
    const tilt = 24 * RAD;
    let frame = 0;

    const turn = ([x, y, z], spin) => {
      const cx = Math.cos(spin), sx = Math.sin(spin);
      const x1 = x * cx - z * sx, z1 = x * sx + z * cx;
      const ct = Math.cos(tilt), st = Math.sin(tilt);
      return [x1, y * ct - z1 * st, y * st + z1 * ct];
    };

    const paint = (seconds) => {
      const size = canvas.clientWidth;
      const c = size / 2, r = size * 0.4;
      const spin = 18 * RAD + seconds * 0.05;
      context.clearRect(0, 0, size, size);

      const glow = context.createRadialGradient(c, c, r * 0.9, c, c, r * 1.22);
      glow.addColorStop(0, rim);
      glow.addColorStop(0.25, rim + '88');
      glow.addColorStop(1, 'transparent');
      context.fillStyle = glow;
      context.fillRect(0, 0, size, size);
      const flare = context.createRadialGradient(c - r * 0.6, c - r * 0.6, 0, c - r * 0.6, c - r * 0.6, r * 0.5);
      flare.addColorStop(0, route + 'aa');
      flare.addColorStop(1, 'transparent');
      context.fillStyle = flare;
      context.fillRect(0, 0, size, size);
      context.beginPath();
      context.arc(c, c, r, 0, Math.PI * 2);
      context.fillStyle = night;
      context.fill();

      context.fillStyle = white;
      for (const dot of dots) {
        const [x, y, z] = turn(dot, spin);
        if (z < 0) continue;
        context.globalAlpha = 0.15 + z * 0.75;
        const s = 0.6 + z * 1.1;
        context.fillRect(c + x * r - s / 2, c - y * r - s / 2, s, s);
      }
      context.globalAlpha = 1;

      context.strokeStyle = route;
      context.fillStyle = route;
      context.lineWidth = Math.max(1, size / 700);
      context.shadowColor = route;
      context.shadowBlur = 10;
      ROUTES.forEach(([from, to], i) => {
        const phase = ((seconds / 2.4) + i / ROUTES.length) % 1;
        const grow = Math.min(1, phase * 1.6);
        const fade = phase > 0.75 ? 1 - (phase - 0.75) / 0.25 : 1;
        const a = vec(from), b = vec(to);
        context.globalAlpha = fade;
        context.beginPath();
        let started = false, last = null;
        for (let k = 0; k <= 40 * grow; k++) {
          const t = k / 40;
          const lift = 1 + Math.sin(Math.PI * t) * 0.18;
          const m = [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
          const len = Math.hypot(...m);
          const [x, y, z] = turn(m.map((v) => (v / len) * lift), spin);
          if (z < -0.1) { started = false; continue; }
          const px = c + x * r, py = c - y * r;
          if (started) context.lineTo(px, py); else context.moveTo(px, py);
          started = true;
          last = [px, py];
        }
        context.stroke();
        if (last) { context.beginPath(); context.arc(last[0], last[1], 2.5, 0, Math.PI * 2); context.fill(); }
      });
      context.globalAlpha = 1;
      context.shadowBlur = 0;
    };

    const fit = () => {
      const density = Math.min(2, devicePixelRatio || 1);
      canvas.width = canvas.clientWidth * density;
      canvas.height = canvas.clientHeight * density;
      context.setTransform(density, 0, 0, density, 0, 0);
      paint(performance.now() / 1000);
    };
    const tick = (now) => {
      paint(now / 1000);
      frame = requestAnimationFrame(tick);
    };
    new ResizeObserver(fit).observe(canvas);
    new IntersectionObserver(([entry]) => {
      cancelAnimationFrame(frame);
      if (entry.isIntersecting && !still.matches) frame = requestAnimationFrame(tick);
    }).observe(root);

    const toggle = root.querySelector('.hero__toggle');
    const close = () => { root.classList.remove('is-open'); toggle.setAttribute('aria-expanded', 'false'); };
    toggle.addEventListener('click', () => {
      const open = !root.classList.contains('is-open');
      root.classList.toggle('is-open', open);
      toggle.setAttribute('aria-expanded', String(open));
    });
    root.addEventListener('keydown', (event) => {
      if (event.key === 'Escape' && root.classList.contains('is-open')) { close(); toggle.focus(); }
    });
    root.querySelectorAll('.hero__link').forEach((link) => link.addEventListener('click', close));
  }

  document.querySelectorAll('.hero').forEach(setup);
})();
</script>

Similar components

Sky hero

Sky hero

Corner frame hero

Corner frame hero

Masthead

Masthead

Mat-top hero

Mat-top hero

Start screen HUD

Start screen HUD

Split words

Split words

Pill-stuck hero

Pill-stuck hero

Masthead

Masthead