Hero Collage
A centred hero with pictures scattered around the title: they open one after the other, then follow the mouse a little, each at its own depth.
View codeA hero that splits visitors in two: a title, then two tall pictures that are links, and the one under the pointer widens while its call to action rises.
With your AI
Say it to your AI. It gets the exact code below, not its best guess, and knows where it goes.
Add the Kodza Hero Paths to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<section class="kodza-hero-paths">
<div class="kodza-hero-paths__inner">
<div class="kodza-hero-paths__head">
<div>
<p class="kodza-hero-paths__eyebrow"><span class="kodza-hero-paths__rise">Studio · two ways in</span></p>
<h1 class="kodza-hero-paths__title"><span class="kodza-hero-paths__line"><span class="kodza-hero-paths__rise">Pick a door.</span></span> <span class="kodza-hero-paths__line"><span class="kodza-hero-paths__rise">Both open.</span></span></h1>
</div>
<p class="kodza-hero-paths__lead">We build the whole site, or we hand you the parts and get out of the way. No discovery call to find out which.</p>
</div>
<div class="kodza-hero-paths__paths">
<a class="kodza-hero-paths__path" href="#">
<span class="kodza-hero-paths__media"><span class="kodza-hero-paths__curtain"><span class="kodza-hero-paths__hold"><img src="https://kodza.dev/media/kz-overflow-1400.webp" srcset="https://kodza.dev/media/kz-overflow-1400.webp 1400w, https://kodza.dev/media/kz-overflow-2400.webp 2400w" sizes="(max-width: 700px) 100vw, 60vw" alt="" width="1400" height="1400" /></span></span></span>
<span class="kodza-hero-paths__body">
<span class="kodza-hero-paths__tag">01 · For teams</span>
<span class="kodza-hero-paths__name">We build it.</span>
<span class="kodza-hero-paths__go"><span class="kodza-hero-paths__go-text">Start a project<svg class="kodza-hero-paths__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /></svg></span></span>
</span>
</a>
<a class="kodza-hero-paths__path" href="#">
<span class="kodza-hero-paths__media"><span class="kodza-hero-paths__curtain"><span class="kodza-hero-paths__hold"><img src="https://kodza.dev/media/kz-arch-1400.webp" srcset="https://kodza.dev/media/kz-arch-1400.webp 1400w, https://kodza.dev/media/kz-arch-2400.webp 2400w" sizes="(max-width: 700px) 100vw, 60vw" alt="" width="1400" height="1400" /></span></span></span>
<span class="kodza-hero-paths__body">
<span class="kodza-hero-paths__tag">02 · For developers</span>
<span class="kodza-hero-paths__name">You build it.</span>
<span class="kodza-hero-paths__go"><span class="kodza-hero-paths__go-text">Browse the parts<svg class="kodza-hero-paths__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /></svg></span></span>
</span>
</a>
</div>
</div>
</section>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Hero Paths
A hero that splits the visitors in two: a title and an intro, then two tall pictures, each one
a link. The one under the pointer (or the keyboard focus) widens while its picture settles and
its call to action rises out of its mask; the other gives it the room. The entrance is played
by the script. Everything is tuned with the --kz-hero-paths-* variables. */
.kodza-hero-paths {
--kz-hero-paths-ink: #0a0a0a;
--kz-hero-paths-dim: rgba(10, 10, 10, 0.62);
--kz-hero-paths-faint: rgba(10, 10, 10, 0.6);
--kz-hero-paths-on-image: #f2f2f0;
--kz-hero-paths-veil: rgba(10, 10, 10, 0.62);
--kz-hero-paths-bg: transparent;
--kz-hero-paths-width: 1440px;
--kz-hero-paths-pad-y: clamp(56px, 7vw, 112px);
--kz-hero-paths-gutter: clamp(16px, 4vw, 40px);
--kz-hero-paths-height: clamp(380px, 32vw, 460px);
--kz-hero-paths-gap: 12px;
--kz-hero-paths-grow: 1.8;
--kz-hero-paths-radius: 16px;
--kz-hero-paths-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
--kz-hero-paths-ease: cubic-bezier(0.22, 1, 0.36, 1);
--kz-hero-paths-sway: cubic-bezier(0.65, 0, 0.35, 1);
container: kodza-hero-paths / inline-size;
box-sizing: border-box;
width: 100%;
padding-top: var(--kz-hero-paths-pad-y);
padding-bottom: var(--kz-hero-paths-gutter);
padding-left: max(var(--kz-hero-paths-gutter), env(safe-area-inset-left, 0px));
padding-right: max(var(--kz-hero-paths-gutter), env(safe-area-inset-right, 0px));
background: var(--kz-hero-paths-bg);
color: var(--kz-hero-paths-ink);
}
.kodza-hero-paths__inner {
max-width: var(--kz-hero-paths-width);
margin: 0 auto;
}
/* Title on the left, intro on the right, on the same bottom line */
.kodza-hero-paths__head {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: end;
column-gap: clamp(24px, 4vw, 64px);
margin-bottom: clamp(32px, 4vw, 56px);
}
.kodza-hero-paths__eyebrow {
margin: 0 0 20px;
overflow: hidden;
font-family: var(--kz-hero-paths-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-paths-faint);
}
.kodza-hero-paths__rise {
display: block;
}
.kodza-hero-paths__title {
margin: 0;
font-size: clamp(40px, 6.2vw, 92px);
font-weight: 700;
line-height: 1;
letter-spacing: -0.05em;
color: var(--kz-hero-paths-ink);
}
.kodza-hero-paths__line {
display: block;
overflow: hidden;
padding-bottom: 0.08em;
margin-bottom: -0.08em;
}
.kodza-hero-paths__lead {
max-width: 34ch;
margin: 0;
font-size: clamp(16px, 1.3vw, 19px);
line-height: 1.55;
color: var(--kz-hero-paths-dim);
text-wrap: pretty;
}
.kodza-hero-paths__paths {
display: flex;
gap: var(--kz-hero-paths-gap);
height: var(--kz-hero-paths-height);
}
/* Each path is a link the size of its picture; it grows by flex, so the other one shrinks with it */
.kodza-hero-paths__path {
position: relative;
isolation: isolate;
overflow: hidden;
display: block;
flex: 1 1 0;
min-width: 0;
border-radius: var(--kz-hero-paths-radius);
color: var(--kz-hero-paths-on-image);
text-decoration: none;
transition: flex-grow 0.8s var(--kz-hero-paths-sway);
}
.kodza-hero-paths__path:focus-visible {
outline: 2px solid var(--kz-hero-paths-ink);
outline-offset: 3px;
}
/* The picture waits slightly zoomed in, and settles as its path opens */
.kodza-hero-paths__media {
position: absolute;
inset: 0;
z-index: -2;
overflow: hidden;
transform: scale(1.1);
transition: transform 1s var(--kz-hero-paths-ease);
}
.kodza-hero-paths__curtain,
.kodza-hero-paths__hold {
display: block;
height: 100%;
}
.kodza-hero-paths__curtain {
overflow: hidden;
}
.kodza-hero-paths__media img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
/* A veil at the foot of the picture, so the words read on any part of it. It lives behind the
curtain with the picture: an empty path shows no grey band before it opens */
.kodza-hero-paths__hold {
position: relative;
}
.kodza-hero-paths__hold::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(to top, var(--kz-hero-paths-veil), transparent 58%);
pointer-events: none;
}
/* The words never wrap, so a path can narrow without them moving */
.kodza-hero-paths__body {
position: absolute;
left: clamp(20px, 2.4vw, 32px);
bottom: clamp(20px, 2.4vw, 32px);
display: grid;
justify-items: start;
gap: 10px;
white-space: nowrap;
}
.kodza-hero-paths__tag {
font-family: var(--kz-hero-paths-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
}
.kodza-hero-paths__name {
font-size: clamp(30px, 3.4vw, 50px);
font-weight: 600;
line-height: 1.05;
letter-spacing: -0.04em;
}
.kodza-hero-paths__go {
display: block;
overflow: hidden;
margin-top: 6px;
}
.kodza-hero-paths__go-text {
display: inline-flex;
align-items: center;
gap: 8px;
font-size: 15px;
font-weight: 500;
line-height: 1.4;
transition: transform 0.55s var(--kz-hero-paths-ease);
}
.kodza-hero-paths__arrow {
flex: none;
width: 16px;
height: 16px;
fill: none;
stroke: currentColor;
stroke-width: 1.5;
stroke-linecap: round;
stroke-linejoin: round;
}
/* With a pointer, the call to action waits under its mask until the path is chosen */
@media (hover: hover) {
.kodza-hero-paths__go-text {
transform: translateY(105%);
}
.kodza-hero-paths__path:hover,
.kodza-hero-paths__path:focus-visible {
flex-grow: var(--kz-hero-paths-grow);
}
.kodza-hero-paths__path:hover .kodza-hero-paths__media,
.kodza-hero-paths__path:focus-visible .kodza-hero-paths__media {
transform: none;
}
.kodza-hero-paths__path:hover .kodza-hero-paths__go-text,
.kodza-hero-paths__path:focus-visible .kodza-hero-paths__go-text {
transform: none;
transition-delay: 0.12s;
}
}
/* Waiting for its entrance: the script sets is-shown and plays the motion in the same frame */
@media (prefers-reduced-motion: no-preference) {
.kodza-hero-paths.is-ready:not(.is-shown) .kodza-hero-paths__rise {
transform: translateY(105%);
}
/* 2px past the edge: a curtain closed exactly on the frame's edge leaks a hairline */
.kodza-hero-paths.is-ready:not(.is-shown) .kodza-hero-paths__curtain {
transform: translateY(calc(-100% - 2px));
}
.kodza-hero-paths.is-ready:not(.is-shown) .kodza-hero-paths__hold {
transform: translateY(calc(100% + 2px));
}
.kodza-hero-paths.is-ready:not(.is-shown) .kodza-hero-paths__lead,
.kodza-hero-paths.is-ready:not(.is-shown) .kodza-hero-paths__body {
opacity: 0;
transform: translateY(20px);
}
}
/* One column: the intro goes under the title and the paths stack */
@container kodza-hero-paths (max-width: 700px) {
.kodza-hero-paths__head {
grid-template-columns: minmax(0, 1fr);
row-gap: 20px;
}
.kodza-hero-paths__paths {
flex-direction: column;
height: auto;
}
.kodza-hero-paths__path {
flex: none;
height: 340px;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-paths *,
.kodza-hero-paths *::before,
.kodza-hero-paths *::after {
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
}
}
/* kodza-guard 0db47577ce18 — generated by Kodza, do not edit.
Theme guard: keeps a site's own CSS (WordPress themes, Bootstrap, CSS resets…) off this
component. :not(#_) is always true and weighs as much as an id, so these lines win over
theme rules made of classes and tags. Customise the component through its --kz-* variables. */
/* What the browser gives, where the component sets it only in some states: at the lowest weight, so its own rules below put it back */
:where(.kodza-hero-paths__eyebrow):not(#_),
:where(.kodza-hero-paths__title):not(#_),
:where(.kodza-hero-paths__lead):not(#_),
:where(.kodza-hero-paths__arrow):not(#_),
:where(.kodza-hero-paths__hold img:where(:not([class*="kodza-"]))):not(#_) {
transition-duration: revert;
}
:where(.kodza-hero-paths__path):not(#_) {
outline: revert;
outline-offset: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-hero-paths__inner:not(#_),
.kodza-hero-paths__head:not(#_),
.kodza-hero-paths__rise:not(#_),
.kodza-hero-paths__line:not(#_),
.kodza-hero-paths__paths:not(#_),
.kodza-hero-paths__media:not(#_),
.kodza-hero-paths__curtain:not(#_),
.kodza-hero-paths__hold:not(#_),
.kodza-hero-paths__body:not(#_),
.kodza-hero-paths__tag:not(#_),
.kodza-hero-paths__name:not(#_),
.kodza-hero-paths__go:not(#_),
.kodza-hero-paths__go-text:not(#_),
.kodza-hero-paths__head div:where(:not([class*="kodza-"])):not(#_) {
box-sizing: revert;
}
.kodza-hero-paths__eyebrow:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-style: revert;
line-height: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-paths__title:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-paths__lead:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-height: revert;
font-family: revert;
font-weight: revert;
font-style: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-paths__path:not(#_) {
border: revert;
margin: revert;
padding: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-hero-paths__arrow:not(#_),
.kodza-hero-paths__hold img:where(:not([class*="kodza-"])):not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-paths__eyebrow:not(#_):where(:not([hidden])),
.kodza-hero-paths__title:not(#_):where(:not([hidden])),
.kodza-hero-paths__lead:not(#_):where(:not([hidden])),
.kodza-hero-paths__arrow:not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-hero-paths__eyebrow:not(#_):where([hidden]),
.kodza-hero-paths__title:not(#_):where([hidden]),
.kodza-hero-paths__lead:not(#_):where([hidden]),
.kodza-hero-paths__arrow:not(#_):where([hidden]) {
display: none;
}
.kodza-hero-paths__hold:not(#_)::after {
box-sizing: revert;
}
/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */
.kodza-hero-paths__eyebrow:not(#_) {
margin: 0 0 20px;
font-family: var(--kz-hero-paths-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-paths-faint);
}
.kodza-hero-paths__title:not(#_) {
margin: 0;
font-size: clamp(40px, 6.2vw, 92px);
font-weight: 700;
line-height: 1;
letter-spacing: -0.05em;
color: var(--kz-hero-paths-ink);
}
.kodza-hero-paths__lead:not(#_) {
max-width: 34ch;
margin: 0;
font-size: clamp(16px, 1.3vw, 19px);
line-height: 1.55;
color: var(--kz-hero-paths-dim);
}
.kodza-hero-paths__path:not(#_) {
position: relative;
display: block;
border-radius: var(--kz-hero-paths-radius);
color: var(--kz-hero-paths-on-image);
text-decoration: none;
transition: flex-grow 0.8s var(--kz-hero-paths-sway);
}
.kodza-hero-paths__path:focus-visible:not(#_) {
outline: 2px solid var(--kz-hero-paths-ink);
outline-offset: 3px;
}
.kodza-hero-paths__media img:not(#_) {
display: block;
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-paths *:where(p, h1, a, img, svg):not(#_) {
transition-duration: 0.01ms !important;
}
}
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Hero Paths
// The widening of the paths is CSS; the script plays the entrance, once the section is in view:
// the title lines rise from their masks, then each picture opens from its top edge down, one after
// the other, and its words come up last. "kodza:replay" plays it again.
(() => {
const SELECTOR = '.kodza-hero-paths';
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const GLIDE = 'cubic-bezier(0.6, 0, 0.1, 1)'; // slow start, long settle
const SOFT = 'cubic-bezier(0.25, 1, 0.5, 1)';
const OPEN = 'cubic-bezier(0.3, 0.5, 0.1, 1)'; // the curtains: a slow start would leave each picture a hairline for 200 ms
const decoded = (root) => Promise.all([...root.querySelectorAll('img')].map((img) => img.decode().catch(() => {})));
// One instance, with its own state: two copies on a page never interfere. Everything it
// starts is tied to `signal` (listeners get { signal }, observers and timers stop on its
// 'abort' event), so kodza:destroy stops it all.
function mount(root, signal) {
const q = (name) => [...root.querySelectorAll(`.kodza-hero-paths__${name}`)];
let running = [];
const stop = () => {
running.forEach((a) => a.cancel());
running = [];
};
const animate = (el, keyframes, options) => {
if (el) running.push(el.animate(keyframes, { easing: GLIDE, fill: 'backwards', ...options }));
};
const rise = (el, delay, duration) => animate(el, [{ transform: 'translateY(105%)' }, { transform: 'none' }], { duration, delay });
const come = (el, delay) => animate(el, [{ opacity: 0, transform: 'translateY(20px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay, easing: SOFT });
const play = async () => {
await decoded(root);
if (signal.aborted) return;
stop();
root.classList.add('is-shown');
q('rise').forEach((el, i) => rise(el, i * 110, i ? 1100 : 1000));
come(q('lead')[0], 520);
q('path').forEach((path, i) => {
const delay = 420 + i * 140;
const at = (name) => path.querySelector(`.kodza-hero-paths__${name}`);
animate(at('curtain'), [{ transform: 'translateY(calc(-100% - 2px))' }, { transform: 'none' }], { duration: 1350, delay, easing: OPEN });
animate(at('hold'), [{ transform: 'translateY(calc(100% + 2px))' }, { transform: 'none' }], { duration: 1350, delay, easing: OPEN });
animate(path.querySelector('img'), [{ transform: 'scale(1.2)' }, { transform: 'none' }], { duration: 2000, delay, easing: SOFT });
come(at('body'), delay + 650);
});
};
if (reduceMotion) {
root.classList.add('is-shown');
return;
}
root.addEventListener('kodza:replay', play, { signal });
signal.addEventListener('abort', stop);
const io = new IntersectionObserver((entries) => {
if (!entries.some((entry) => entry.isIntersecting)) return;
io.disconnect();
play();
}, { rootMargin: '0px 0px -15% 0px' });
signal.addEventListener('abort', () => io.disconnect());
Promise.all([document.fonts?.ready, decoded(root)]).then(() => {
if (!signal.aborted) io.observe(root);
});
}
// Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
// event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
// markup back. For themes and apps that swap content without a page load. Each running root
// keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
// component inside another one is saved as written, not half-started, and stopped with it.
const KODZA = Symbol.for('kodza');
const instances = new WeakMap();
const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
const put = (el, saved) => {
[...el.attributes].forEach((a) => el.removeAttribute(a.name));
saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
el.innerHTML = saved.html;
};
// The markup inside a root as written: Kodza components already running in it give back their own
const written = (root) => {
const all = [...root.querySelectorAll('*')];
if (!all.some((el) => el[KODZA])) return root.innerHTML;
const copy = root.cloneNode(true);
const twins = copy.querySelectorAll('*');
let last = null;
all.forEach((el, i) => {
if (!el[KODZA] || last?.contains(el)) return;
last = el;
put(twins[i], el[KODZA]);
});
return copy.innerHTML;
};
const init = (scope) => find(scope).forEach((root) => {
if (root.classList.contains('is-ready')) return; // already running, maybe from another copy of this script
const controller = new AbortController();
const saved = { html: written(root), attrs: attrsOf(root), stop: () => destroy(root) };
instances.set(root, { controller, saved });
root[KODZA] = saved;
mount(root, controller.signal);
root.classList.add('is-ready');
});
const destroy = (scope) => find(scope).forEach((root) => {
const instance = instances.get(root);
if (!instance) return;
instances.delete(root);
// The Kodza components running inside it stop first: once its markup is put back, their own
// script could not find them any more
root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
instance.controller.abort();
delete root[KODZA];
put(root, instance.saved);
});
document.addEventListener('kodza:init', (event) => init(event.detail?.root));
document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
init();
// Loaded in <head>, the script runs before the markup exists: once more when it is parsed
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
'use client';
// Kodza — Hero Paths, for React. From https://kodza.dev/components/hero-paths/
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Next to this file: hero-paths.css and hero-paths.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './hero-paths.css';
export type HeroPathsProps = Omit<ComponentPropsWithoutRef<'section'>, "children" | "vars"> & {
/** Settings, as CSS variables on the root */
vars?: {
/** default: #0a0a0a */
"--kz-hero-paths-ink"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-hero-paths-dim"?: string | number;
/** default: rgba(10, 10, 10, 0.6) */
"--kz-hero-paths-faint"?: string | number;
/** default: #f2f2f0 */
"--kz-hero-paths-on-image"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-hero-paths-veil"?: string | number;
/** default: transparent */
"--kz-hero-paths-bg"?: string | number;
/** default: 1440px */
"--kz-hero-paths-width"?: string | number;
/** default: clamp(56px, 7vw, 112px) */
"--kz-hero-paths-pad-y"?: string | number;
/** default: clamp(16px, 4vw, 40px) */
"--kz-hero-paths-gutter"?: string | number;
/** default: clamp(380px, 32vw, 460px) */
"--kz-hero-paths-height"?: string | number;
/** default: 12px */
"--kz-hero-paths-gap"?: string | number;
/** default: 1.8 */
"--kz-hero-paths-grow"?: string | number;
/** default: 16px */
"--kz-hero-paths-radius"?: string | number;
/** default: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace */
"--kz-hero-paths-mono"?: string | number;
/** default: cubic-bezier(0.22, 1, 0.36, 1) */
"--kz-hero-paths-ease"?: string | number;
/** default: cubic-bezier(0.65, 0, 0.35, 1) */
"--kz-hero-paths-sway"?: string | number;
};
className?: string;
};
export function HeroPaths({ vars, className, style, ...rest }: HeroPathsProps) {
const ref = useRef<ComponentRef<'section'>>(null);
const classes = ["kodza-hero-paths", className].filter(Boolean).join(' ');
// Everything the markup is made of: when it changes, React gets a fresh element (see the top)
const key = JSON.stringify([classes, vars, style, rest]);
// Starts the script on this element once React has rendered it, stops it when it goes
useEffect(() => {
const root = ref.current;
let live = true;
// @ts-ignore: a plain script, no types to find
import('./hero-paths.js').then(() => {
if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
});
return () => {
live = false;
document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
};
}, [key]);
return (
<section key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<div className="kodza-hero-paths__inner">
<div className="kodza-hero-paths__head">
<div>
<p className="kodza-hero-paths__eyebrow">
<span className="kodza-hero-paths__rise">Studio · two ways in</span>
</p>
<h1 className="kodza-hero-paths__title">
<span className="kodza-hero-paths__line">
<span className="kodza-hero-paths__rise">Pick a door.</span>
</span>
{' '}
<span className="kodza-hero-paths__line">
<span className="kodza-hero-paths__rise">Both open.</span>
</span>
</h1>
</div>
<p className="kodza-hero-paths__lead">We build the whole site, or we hand you the parts and get out of the way. No discovery call to find out which.</p>
</div>
<div className="kodza-hero-paths__paths">
<a className="kodza-hero-paths__path" href="#">
<span className="kodza-hero-paths__media">
<span className="kodza-hero-paths__curtain">
<span className="kodza-hero-paths__hold">
<img src="https://kodza.dev/media/kz-overflow-1400.webp" srcSet="https://kodza.dev/media/kz-overflow-1400.webp 1400w, https://kodza.dev/media/kz-overflow-2400.webp 2400w" sizes="(max-width: 700px) 100vw, 60vw" alt="" width="1400" height="1400" />
</span>
</span>
</span>
{' '}
<span className="kodza-hero-paths__body">
<span className="kodza-hero-paths__tag">01 · For teams</span>
{' '}
<span className="kodza-hero-paths__name">We build it.</span>
{' '}
<span className="kodza-hero-paths__go">
<span className="kodza-hero-paths__go-text">Start a project<svg className="kodza-hero-paths__arrow" viewBox="0 0 16 16" aria-hidden="true"> <path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /> </svg></span>
</span>
</span>
</a>
{' '}
<a className="kodza-hero-paths__path" href="#">
<span className="kodza-hero-paths__media">
<span className="kodza-hero-paths__curtain">
<span className="kodza-hero-paths__hold">
<img src="https://kodza.dev/media/kz-arch-1400.webp" srcSet="https://kodza.dev/media/kz-arch-1400.webp 1400w, https://kodza.dev/media/kz-arch-2400.webp 2400w" sizes="(max-width: 700px) 100vw, 60vw" alt="" width="1400" height="1400" />
</span>
</span>
</span>
{' '}
<span className="kodza-hero-paths__body">
<span className="kodza-hero-paths__tag">02 · For developers</span>
{' '}
<span className="kodza-hero-paths__name">You build it.</span>
{' '}
<span className="kodza-hero-paths__go">
<span className="kodza-hero-paths__go-text">Browse the parts<svg className="kodza-hero-paths__arrow" viewBox="0 0 16 16" aria-hidden="true"> <path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /> </svg></span>
</span>
</span>
</a>
</div>
</div>
</section>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.