kitbash Sign in Connect agent
Components

Halftone globe hero

A twinkling starfield, one giant condensed word fading into a halftone planet that rises from below, orbit arcs, pink target markers, a caption chip, a pink booking bar and a day/night switch.

Part of the style

Starfield Halftone Globe

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --night: #ff4401;
  --void: #fda58e;
  --cream: #21131b;
  --white: #160f13;
  --muted: #42012e;
  --hairline: rgba(22, 15, 19, 0.16);
  --hairline-strong: rgba(22, 15, 19, 0.42);
  --chip: #f45a33;
  --star: rgba(22, 15, 19, 0.55);
  --pink: #440130;
  --pink-deep: #5c0b42;
}
</style>

<section class="hero" aria-labelledby="hero-title">
  <canvas class="hero__sky" aria-hidden="true"></canvas>
  <svg class="hero__orbits" viewBox="0 0 1440 900" preserveAspectRatio="xMidYMax slice" aria-hidden="true">
    <g fill="none" stroke="currentColor" stroke-width="1">
      <circle cx="720" cy="1240" r="760"/>
      <circle cx="720" cy="1240" r="900"/>
      <circle cx="720" cy="1240" r="1060"/>
      <path d="M140 446 L268 716 M1336 386 L1214 660"/>
    </g>
  </svg>
  <canvas class="hero__globe" data-picture="assets/earth.jpg" data-disc="450 450 413" role="img" aria-label="The Earth seen from space, printed as a black and white halftone"></canvas>
  <span class="hero__marker hero__marker--left" aria-hidden="true"></span>
  <span class="hero__marker hero__marker--right" aria-hidden="true"></span>

  <h1 class="hero__title" id="hero-title">Nadir</h1>

  <div class="hero__copy">
    <p class="hero__chip"><span class="hero__when hero__when--night">After dark we are</span><span class="hero__when hero__when--day">By day we are</span></p>
    <p class="hero__lead">
      <span class="hero__when hero__when--night">a low room with loud speakers<br>and slow, serious cocktails</span>
      <span class="hero__when hero__when--day">a quiet café with long tables<br>and a kitchen that never rushes</span>
    </p>
    <a class="hero__cta" href="#">Book a table</a>
  </div>

  <button class="hero__switch" type="button" role="switch" aria-checked="false" aria-label="Day mode">
    <span class="hero__switch-label">Night</span>
    <span class="hero__switch-track" aria-hidden="true"><span class="hero__switch-dot"></span></span>
    <span class="hero__switch-label">Day</span>
  </button>
</section>

<style>
  .hero {
    --hero-ground: var(--night);
    --hero-ink: var(--white);
    --hero-word: var(--cream);
    position: relative;
    isolation: isolate;
    height: clamp(640px, 62vw, 900px);
    overflow: hidden;
    background-color: var(--hero-ground);
    color: var(--hero-ink);
    text-align: center;
    transition: background-color 600ms var(--ease), color 600ms var(--ease);
  }
  .hero.is-day {
    --hero-ground: var(--cream);
    --hero-ink: var(--night);
    --hero-word: var(--night);
  }
  .hero__sky {
    position: absolute;
    inset: 0;
    z-index: -3;
    width: 100%;
    height: 100%;
    color: var(--hero-ink);
    transition: opacity 600ms var(--ease);
  }
  .hero.is-day .hero__sky {
    opacity: 0.45;
  }
  .hero__orbits {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    color: var(--hero-ink);
    opacity: 0.22;
  }

  .hero__globe {
    position: absolute;
    left: 50%;
    top: 52%;
    z-index: -1;
    width: min(70vw, 920px);
    aspect-ratio: 1;
    transform: translate(-50%, 18%);
    opacity: 0;
    transition: transform var(--slow) var(--ease-out), opacity var(--slow) var(--ease-out);
  }
  .hero.is-ready .hero__globe {
    transform: translate(-50%, 0);
    opacity: 1;
  }

  .hero__title {
    position: relative;
    margin: clamp(48px, 9vw, 130px) 0 0;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: var(--display-xl);
    line-height: var(--display-leading);
    letter-spacing: -0.005em;
    text-transform: uppercase;
    color: transparent;
    background: linear-gradient(to bottom, var(--hero-word) 0 58%, transparent 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }

  .hero__marker {
    position: absolute;
    width: 24px;
    height: 24px;
    background:
      radial-gradient(circle, var(--pink) 0 6px, transparent 6.5px),
      linear-gradient(var(--hero-ink), var(--hero-ink)) 0 0 / 6px 1.5px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 0 0 / 1.5px 6px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 100% 0 / 6px 1.5px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 100% 0 / 1.5px 6px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 0 100% / 6px 1.5px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 0 100% / 1.5px 6px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 100% 100% / 6px 1.5px no-repeat,
      linear-gradient(var(--hero-ink), var(--hero-ink)) 100% 100% / 1.5px 6px no-repeat;
    opacity: 0.9;
    animation: hero-blink 2.4s var(--ease) infinite;
  }
  .hero__marker--left {
    left: 9.7%;
    top: 49.5%;
    translate: -50% -50%;
  }
  .hero__marker--right {
    left: 92.8%;
    top: 42.8%;
    translate: -50% -50%;
    animation-delay: -1.2s;
  }
  @keyframes hero-blink {
    50% { opacity: 0.35; }
  }

  .hero__copy {
    position: absolute;
    left: 50%;
    top: 61%;
    display: grid;
    justify-items: center;
    gap: var(--space-s);
    width: min(420px, calc(100% - 2 * var(--edge)));
    translate: -50% 0;
  }
  .hero__chip {
    margin: 0;
    padding: 2px var(--space-xs);
    background: var(--void);
    color: var(--white);
    font-size: var(--text-xl);
    font-weight: 500;
    line-height: 1.2;
    text-transform: uppercase;
  }
  .hero.is-day .hero__chip {
    background: var(--night);
    color: var(--cream);
  }
  .hero__lead {
    margin: 0;
    font-size: var(--text-l);
    line-height: 1.3;
    color: var(--white);
    text-shadow: 0 0 4px var(--void), 0 0 10px var(--void), 0 0 18px var(--void);
  }
  .hero__when--day,
  .hero.is-day .hero__when--night {
    display: none;
  }
  .hero.is-day .hero__when--day {
    display: inline;
  }
  .hero__cta {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 48px;
    margin-top: var(--space-m);
    border-radius: var(--radius-s);
    background: var(--pink);
    color: var(--white);
    font-size: var(--text-l);
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color var(--quick) var(--ease);
  }
  .hero__cta:hover {
    background: var(--pink-deep);
  }
  .hero__cta:focus-visible,
  .hero__switch:focus-visible {
    outline: var(--rule-bold) solid var(--hero-ink);
    outline-offset: 3px;
  }

  .hero__switch {
    position: absolute;
    left: var(--edge);
    bottom: var(--space-l);
    display: inline-flex;
    align-items: center;
    gap: var(--space-s);
    min-height: 44px;
    padding: 0 var(--space-s);
    border: var(--rule) solid var(--hairline-strong);
    border-radius: var(--pill);
    background: var(--hero-ground);
    color: var(--hero-ink);
    font: 500 var(--text-s) / 1 var(--font-body);
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 600ms var(--ease), color 600ms var(--ease);
  }
  .hero.is-day .hero__switch {
    border-color: var(--night);
  }
  .hero__switch-track {
    position: relative;
    width: 40px;
    height: 20px;
    border-radius: var(--pill);
    background: var(--chip);
  }
  .hero__switch-dot {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-round);
    background: var(--pink);
    transition: transform var(--quick) var(--ease);
  }
  .hero.is-day .hero__switch-dot {
    transform: translateX(20px);
  }

  @media (max-width: 760px) {
    .hero {
      height: clamp(640px, 190vw, 780px);
    }
    .hero__title {
      margin-top: clamp(120px, 40vw, 180px);
      font-size: clamp(110px, 33vw, 200px);
    }
    .hero__globe {
      top: 46%;
      width: 150vw;
    }
    .hero__copy {
      top: auto;
      bottom: 96px;
    }
    .hero__marker--left { left: 12%; top: 22%; }
    .hero__marker--right { left: 88%; top: 22%; }
  }
  @media (prefers-reduced-motion: reduce) {
    .hero__globe { transition: none; }
    .hero__marker { animation: none; }
  }
</style>

<script>
  (() => {
    const still = matchMedia('(prefers-reduced-motion: reduce)');

    // Stars: fixed positions from a seeded random, each twinkling on its own phase.
    function sky(canvas) {
      const context = canvas.getContext('2d');
      let seed = 7;
      const random = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
      const stars = Array.from({ length: 260 }, () => ({
        x: random(), y: random(), r: random() < 0.08 ? 1.6 : 0.5 + random() * 0.7, phase: random() * 6.3, speed: 0.6 + random() * 1.6,
      }));
      const paint = (seconds) => {
        const width = canvas.clientWidth;
        const height = canvas.clientHeight;
        context.clearRect(0, 0, width, height);
        context.fillStyle = getComputedStyle(canvas).color;
        for (const star of stars) {
          context.globalAlpha = 0.25 + 0.45 * (0.5 + 0.5 * Math.sin(seconds * star.speed + star.phase));
          context.beginPath();
          context.arc(star.x * width, star.y * height, star.r, 0, Math.PI * 2);
          context.fill();
        }
        context.globalAlpha = 1;
      };
      let frame = 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(canvas);
    }

    // Globe: the photograph is read pixel by pixel and redrawn as a 45 degree line-screen halftone, lit from the top left.
    function globe(canvas, root) {
      const context = canvas.getContext('2d');
      const picture = new Image();
      const [cx, cy, cr] = canvas.dataset.disc.split(' ').map(Number);
      let samples = null;
      const size = 260;
      const draw = () => {
        if (!samples) return;
        const density = Math.min(2, devicePixelRatio || 1);
        const side = canvas.clientWidth;
        canvas.width = side * density;
        canvas.height = side * density;
        context.setTransform(density, 0, 0, density, 0, 0);
        const radius = side / 2;
        const css = getComputedStyle(canvas);
        context.fillStyle = css.getPropertyValue('--void').trim();
        context.beginPath();
        context.arc(radius, radius, radius, 0, Math.PI * 2);
        context.fill();
        const cell = Math.max(3.2, side / 190);
        const cos = Math.SQRT1_2;
        context.fillStyle = css.getPropertyValue('--cream').trim();
        const reach = radius * 1.5;
        for (let u = -reach; u <= reach; u += cell) {
          for (let v = -reach; v <= reach; v += cell) {
            const x = (u - v) * cos;
            const y = (u + v) * cos;
            const nx = x / radius;
            const ny = y / radius;
            const d2 = nx * nx + ny * ny;
            if (d2 >= 1) continue;
            const sx = Math.min(size - 1, Math.max(0, Math.round((nx * 0.5 + 0.5) * (size - 1))));
            const sy = Math.min(size - 1, Math.max(0, Math.round((ny * 0.5 + 0.5) * (size - 1))));
            const nz = Math.sqrt(1 - d2);
            const light = Math.max(0, -0.45 * nx - 0.55 * ny + 0.7 * nz);
            let tone = samples[sy * size + sx] / 255;
            tone = Math.min(1, Math.pow(tone, 0.8) * 1.35) * (0.25 + 0.95 * light);
            if (tone < 0.04) continue;
            context.beginPath();
            context.arc(radius + x, radius + y, cell * 0.56 * Math.sqrt(Math.min(1, tone)), 0, Math.PI * 2);
            context.fill();
          }
        }
        root.classList.add('is-ready');
      };
      picture.onload = () => {
        const sampler = document.createElement('canvas');
        sampler.width = size;
        sampler.height = size;
        const sample = sampler.getContext('2d', { willReadFrequently: true });
        sample.drawImage(picture, cx - cr, cy - cr, cr * 2, cr * 2, 0, 0, size, size);
        const data = sample.getImageData(0, 0, size, size).data;
        samples = new Uint8ClampedArray(size * size);
        for (let i = 0; i < samples.length; i++) {
          samples[i] = 0.3 * data[i * 4] + 0.59 * data[i * 4 + 1] + 0.11 * data[i * 4 + 2];
        }
        draw();
      };
      picture.onerror = () => root.classList.add('is-ready');
      picture.src = canvas.dataset.picture;
      let last = 0;
      new ResizeObserver(() => {
        if (Math.abs(canvas.clientWidth - last) < 2) return;
        last = canvas.clientWidth;
        draw();
      }).observe(canvas);
    }

    document.querySelectorAll('.hero').forEach((root) => {
      sky(root.querySelector('.hero__sky'));
      globe(root.querySelector('.hero__globe'), root);
      const toggle = root.querySelector('.hero__switch');
      toggle.addEventListener('click', () => {
        const day = !root.classList.contains('is-day');
        root.classList.toggle('is-day', day);
        toggle.setAttribute('aria-checked', String(day));
      });
    });
  })();
</script>

Similar components

Spectrum letters hero

Spectrum letters hero

Opening line

Opening line

Device hero

Device hero

Painted scene hero

Painted scene hero

Typing hero with window

Typing hero with window

Particle halo hero

Particle halo hero

Dot-mosaic hero

Dot-mosaic hero

Lobby Kiosk

Lobby Kiosk