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 sets the name across the whole width, ink edge to ink edge: its letters rise one by one and a wide picture opens right under them.
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 Wordmark to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<section class="kodza-hero-wordmark">
<div class="kodza-hero-wordmark__inner">
<p class="kodza-hero-wordmark__eyebrow"><span class="kodza-hero-wordmark__rise">Independent studio · Lyon, since 2019</span></p>
<h1 class="kodza-hero-wordmark__title">Hotfix</h1>
<p class="kodza-hero-wordmark__lead">Sites for brands that were promised one last quarter. Ours go live on a Tuesday.</p>
<div class="kodza-hero-wordmark__actions">
<a class="kodza-hero-wordmark__button kodza-hero-wordmark__button--ink" href="#">See the work<svg class="kodza-hero-wordmark__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /></svg></a>
<a class="kodza-hero-wordmark__button kodza-hero-wordmark__button--soft" href="#">Book a call</a>
</div>
<div class="kodza-hero-wordmark__media"><div class="kodza-hero-wordmark__curtain"><div class="kodza-hero-wordmark__hold"><img src="https://kodza.dev/media/kz-gap-2400.webp" srcset="https://kodza.dev/media/kz-gap-1400.webp 1400w, https://kodza.dev/media/kz-gap-2400.webp 2400w" sizes="100vw" alt="A long concrete wall, split by a slot of low sun" width="2400" height="1000" fetchpriority="high" /></div></div></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 Wordmark
The name set across the whole width, ink edge to ink edge, with a wide picture right under
its letters. The script sizes the name to the column (again on resize and once the font is
in), then the letters rise one after the other and the picture opens from their baseline down.
Everything is tuned with the --kz-hero-wordmark-* variables. */
.kodza-hero-wordmark {
--kz-hero-wordmark-ink: #0a0a0a;
--kz-hero-wordmark-paper: #f2f2f0;
--kz-hero-wordmark-dim: rgba(10, 10, 10, 0.62);
--kz-hero-wordmark-faint: rgba(10, 10, 10, 0.6);
--kz-hero-wordmark-soft: rgba(10, 10, 10, 0.07);
--kz-hero-wordmark-bg: transparent;
--kz-hero-wordmark-width: none;
--kz-hero-wordmark-pad-top: clamp(56px, 7vw, 112px);
--kz-hero-wordmark-gutter: clamp(16px, 4vw, 40px);
--kz-hero-wordmark-gap: clamp(10px, 1.2vw, 18px);
--kz-hero-wordmark-radius: 16px;
--kz-hero-wordmark-ratio: 12 / 5;
--kz-hero-wordmark-weight: 700;
--kz-hero-wordmark-tracking: -0.04em;
--kz-hero-wordmark-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
--kz-hero-wordmark-ease: cubic-bezier(0.22, 1, 0.36, 1);
container: kodza-hero-wordmark / inline-size;
box-sizing: border-box;
width: 100%;
padding-top: var(--kz-hero-wordmark-pad-top);
padding-bottom: var(--kz-hero-wordmark-gutter);
padding-left: max(var(--kz-hero-wordmark-gutter), env(safe-area-inset-left, 0px));
padding-right: max(var(--kz-hero-wordmark-gutter), env(safe-area-inset-right, 0px));
overflow-x: clip;
background: var(--kz-hero-wordmark-bg);
color: var(--kz-hero-wordmark-ink);
}
.kodza-hero-wordmark__inner {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
grid-template-areas:
"eyebrow ."
"lead actions"
"title title"
"media media";
column-gap: clamp(24px, 4vw, 64px);
max-width: var(--kz-hero-wordmark-width);
margin: 0 auto;
}
.kodza-hero-wordmark__eyebrow {
grid-area: eyebrow;
margin: 0 0 16px;
overflow: hidden;
font-family: var(--kz-hero-wordmark-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-wordmark-faint);
}
.kodza-hero-wordmark__rise {
display: block;
}
.kodza-hero-wordmark__lead {
grid-area: lead;
align-self: end;
max-width: 36ch;
margin: 0;
font-size: clamp(16px, 1.3vw, 19px);
line-height: 1.55;
color: var(--kz-hero-wordmark-dim);
text-wrap: pretty;
}
/* The name: the script fills in the size and the four measures below, so the ink of the first
letter starts on the left edge, the last one ends on the right edge and the box stops on the
baseline. Without the script, a size that comes close */
.kodza-hero-wordmark__title {
grid-area: title;
height: var(--kz-hero-wordmark-height, auto);
margin: clamp(36px, 5vw, 72px) 0 0;
font-size: var(--kz-hero-wordmark-size, 35cqi);
font-weight: var(--kz-hero-wordmark-weight);
line-height: 1.2;
letter-spacing: var(--kz-hero-wordmark-tracking);
white-space: nowrap;
color: var(--kz-hero-wordmark-ink);
}
/* Pulled up to the ink, its empty top would cover the buttons: clicks go through it */
.kodza-hero-wordmark__word {
display: flex;
pointer-events: none;
margin-top: calc(var(--kz-hero-wordmark-lift, 0px) * -1);
margin-left: calc(var(--kz-hero-wordmark-shift, 0px) * -1);
}
/* Each letter is its own mask, cut on the baseline: it rises from the edge the picture opens on.
Only the height is clipped, so the tight tracking never shaves the side of a glyph */
.kodza-hero-wordmark__letter {
display: block;
flex: none;
height: var(--kz-hero-wordmark-mask, auto);
overflow-x: visible;
overflow-y: clip;
white-space: pre;
}
.kodza-hero-wordmark__glyph {
display: inline-block;
}
/* Empty, it sits on the baseline: the script reads the line from it */
.kodza-hero-wordmark__base {
display: inline-block;
}
.kodza-hero-wordmark__actions {
grid-area: actions;
align-self: end;
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.kodza-hero-wordmark__button {
position: relative;
isolation: isolate;
overflow: hidden;
box-sizing: border-box;
display: inline-flex;
align-items: center;
gap: 10px;
height: 52px;
padding: 0 26px;
border: 0;
border-radius: 999px;
font-family: inherit;
font-size: 15px;
font-weight: 500;
line-height: 1;
white-space: nowrap;
text-decoration: none;
cursor: pointer;
}
.kodza-hero-wordmark__button:focus-visible {
outline: 2px solid var(--kz-hero-wordmark-ink);
outline-offset: 3px;
}
/* Solid: the arrow steps forward on hover */
.kodza-hero-wordmark__button--ink {
background: var(--kz-hero-wordmark-ink);
color: var(--kz-hero-wordmark-paper);
}
.kodza-hero-wordmark__arrow {
flex: none;
width: 16px;
height: 16px;
fill: none;
stroke: currentColor;
stroke-width: 1.5;
stroke-linecap: round;
stroke-linejoin: round;
transition: transform 0.3s var(--kz-hero-wordmark-ease);
}
/* Soft: ink rises from the bottom edge on hover */
.kodza-hero-wordmark__button--soft {
background: var(--kz-hero-wordmark-soft);
color: var(--kz-hero-wordmark-ink);
transition: color 0.4s var(--kz-hero-wordmark-ease);
}
.kodza-hero-wordmark__button--soft::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: var(--kz-hero-wordmark-ink);
transform: translateY(101%);
transition: transform 0.4s var(--kz-hero-wordmark-ease);
}
@media (hover: hover) {
.kodza-hero-wordmark__button--ink:hover .kodza-hero-wordmark__arrow {
transform: translateX(4px);
}
.kodza-hero-wordmark__button--soft:hover {
color: var(--kz-hero-wordmark-paper);
}
.kodza-hero-wordmark__button--soft:hover::before {
transform: none;
}
}
/* The curtain: the middle layer slides down from above while the inner one slides up into
place, so the picture is uncovered from the top edge down and never moves itself */
.kodza-hero-wordmark__media {
grid-area: media;
margin-top: var(--kz-hero-wordmark-gap);
aspect-ratio: var(--kz-hero-wordmark-ratio);
overflow: hidden;
border-radius: var(--kz-hero-wordmark-radius);
}
.kodza-hero-wordmark__curtain,
.kodza-hero-wordmark__hold {
height: 100%;
}
.kodza-hero-wordmark__curtain {
overflow: hidden;
}
.kodza-hero-wordmark__media img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
/* 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-wordmark.is-ready:not(.is-shown) .kodza-hero-wordmark__rise,
.kodza-hero-wordmark.is-ready:not(.is-shown) .kodza-hero-wordmark__glyph {
transform: translateY(105%);
}
/* 2px past the edge: a curtain closed exactly on the frame's edge leaks a hairline */
.kodza-hero-wordmark.is-ready:not(.is-shown) .kodza-hero-wordmark__curtain {
transform: translateY(calc(-100% - 2px));
}
.kodza-hero-wordmark.is-ready:not(.is-shown) .kodza-hero-wordmark__hold {
transform: translateY(calc(100% + 2px));
}
.kodza-hero-wordmark.is-ready:not(.is-shown) .kodza-hero-wordmark__lead,
.kodza-hero-wordmark.is-ready:not(.is-shown) .kodza-hero-wordmark__actions {
opacity: 0;
transform: translateY(20px);
}
}
/* One column: the name comes right after the label, the picture under it goes 4:3, and the
words and buttons follow */
@container kodza-hero-wordmark (max-width: 700px) {
.kodza-hero-wordmark__inner {
grid-template-columns: minmax(0, 1fr);
grid-template-areas:
"eyebrow"
"title"
"media"
"lead"
"actions";
}
.kodza-hero-wordmark__title {
margin-top: 6px;
}
.kodza-hero-wordmark__media {
aspect-ratio: 4 / 3;
}
.kodza-hero-wordmark__lead {
margin-top: 24px;
}
.kodza-hero-wordmark__actions {
margin-top: 24px;
}
.kodza-hero-wordmark__button {
flex: 1 1 auto;
justify-content: center;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-wordmark *,
.kodza-hero-wordmark *::before,
.kodza-hero-wordmark *::after {
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
}
}
/* kodza-guard c20c8dad3f99 — 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-wordmark__eyebrow):not(#_),
:where(.kodza-hero-wordmark__title):not(#_),
:where(.kodza-hero-wordmark__lead):not(#_),
:where(.kodza-hero-wordmark__hold img:where(:not([class*="kodza-"]))):not(#_) {
transition-duration: revert;
}
:where(.kodza-hero-wordmark__button):not(#_) {
outline: revert;
transition: revert;
outline-offset: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-hero-wordmark__inner:not(#_),
.kodza-hero-wordmark__rise:not(#_),
.kodza-hero-wordmark__word:not(#_),
.kodza-hero-wordmark__letter:not(#_),
.kodza-hero-wordmark__glyph:not(#_),
.kodza-hero-wordmark__base:not(#_),
.kodza-hero-wordmark__actions:not(#_),
.kodza-hero-wordmark__media:not(#_),
.kodza-hero-wordmark__curtain:not(#_),
.kodza-hero-wordmark__hold:not(#_) {
box-sizing: revert;
}
.kodza-hero-wordmark__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-wordmark__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-wordmark__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-wordmark__button:not(#_) {
margin: revert;
list-style: revert;
float: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: 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;
}
.kodza-hero-wordmark__arrow: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;
}
.kodza-hero-wordmark__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-wordmark__eyebrow:not(#_):where(:not([hidden])),
.kodza-hero-wordmark__title:not(#_):where(:not([hidden])),
.kodza-hero-wordmark__lead:not(#_):where(:not([hidden])),
.kodza-hero-wordmark__arrow:not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-hero-wordmark__eyebrow:not(#_):where([hidden]),
.kodza-hero-wordmark__title:not(#_):where([hidden]),
.kodza-hero-wordmark__lead:not(#_):where([hidden]),
.kodza-hero-wordmark__arrow:not(#_):where([hidden]) {
display: none;
}
/* 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-wordmark__eyebrow:not(#_) {
margin: 0 0 16px;
font-family: var(--kz-hero-wordmark-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-wordmark-faint);
}
.kodza-hero-wordmark__lead:not(#_) {
max-width: 36ch;
margin: 0;
font-size: clamp(16px, 1.3vw, 19px);
line-height: 1.55;
color: var(--kz-hero-wordmark-dim);
}
.kodza-hero-wordmark__title:not(#_) {
margin: clamp(36px, 5vw, 72px) 0 0;
font-size: var(--kz-hero-wordmark-size, 35cqi);
font-weight: var(--kz-hero-wordmark-weight);
line-height: 1.2;
letter-spacing: var(--kz-hero-wordmark-tracking);
color: var(--kz-hero-wordmark-ink);
}
.kodza-hero-wordmark__button:not(#_) {
position: relative;
box-sizing: border-box;
display: inline-flex;
padding: 0 26px;
border: 0;
border-radius: 999px;
font-family: inherit;
font-size: 15px;
font-weight: 500;
line-height: 1;
text-decoration: none;
}
.kodza-hero-wordmark__button:focus-visible:not(#_) {
outline: 2px solid var(--kz-hero-wordmark-ink);
outline-offset: 3px;
}
.kodza-hero-wordmark__button--ink:not(#_) {
background: var(--kz-hero-wordmark-ink);
color: var(--kz-hero-wordmark-paper);
}
.kodza-hero-wordmark__arrow:not(#_) {
transition: transform 0.3s var(--kz-hero-wordmark-ease);
}
.kodza-hero-wordmark__button--soft:not(#_) {
background: var(--kz-hero-wordmark-soft);
color: var(--kz-hero-wordmark-ink);
transition: color 0.4s var(--kz-hero-wordmark-ease);
}
@media (hover: hover) {
.kodza-hero-wordmark__button--soft:hover:not(#_) {
color: var(--kz-hero-wordmark-paper);
}
}
.kodza-hero-wordmark__media img:not(#_) {
display: block;
}
@container kodza-hero-wordmark (max-width: 700px) {
.kodza-hero-wordmark__title:not(#_) {
margin-top: 6px;
}
}
@container kodza-hero-wordmark (max-width: 700px) {
.kodza-hero-wordmark__lead:not(#_) {
margin-top: 24px;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-wordmark *:where(p, h1, a, svg, img):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 Wordmark
// Sets the name across the whole column, ink edge to ink edge: each letter goes in its own mask,
// the name is measured at 100px (in the page, and on a canvas for the ink around each glyph) and
// sized to the column, again whenever its width changes or a font comes in. Then the entrance,
// once the section is in view: the letters rise one after the other from the baseline, the picture
// opens from that same line down, the words and buttons follow. "kodza:replay" plays it again.
(() => {
const SELECTOR = '.kodza-hero-wordmark';
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 curtain: a slow start would leave the picture a hairline for 200 ms
const REF = 100; // the size the name is measured at, in px
const VARS = ['size', 'height', 'lift', 'shift', 'mask'].map((name) => `--kz-hero-wordmark-${name}`);
const decoded = (root) => Promise.all([...root.querySelectorAll('img')].map((img) => img.decode().catch(() => {})));
const span = (name) => {
const el = document.createElement('span');
el.className = `kodza-hero-wordmark__${name}`;
return el;
};
// The ink of one glyph at the reference size, from its origin: where it starts and ends, how
// far it rises above the baseline and drops below it
let context;
const ink = (char, font) => {
context ||= document.createElement('canvas').getContext('2d');
context.font = font;
const m = context.measureText(char);
return { left: -m.actualBoundingBoxLeft, right: m.actualBoundingBoxRight, ascent: m.actualBoundingBoxAscent, descent: Math.max(0, m.actualBoundingBoxDescent) };
};
// 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 = (s) => root.querySelector(s);
const title = q('.kodza-hero-wordmark__title');
if (!title) return;
// One mask per letter; screen readers keep the name whole
const text = title.textContent.trim();
const chars = [...text];
const word = span('word');
word.setAttribute('aria-hidden', 'true');
const glyphs = chars.map((char) => {
const letter = span('letter');
const glyph = span('glyph');
glyph.textContent = char;
letter.append(glyph);
word.append(letter);
return glyph;
});
const base = span('base');
glyphs[0]?.after(base);
title.setAttribute('aria-label', text);
title.replaceChildren(word);
// Measured at the reference size, then scaled: the ink of the first letter on the left edge,
// the last one on the right edge, the box from the top of the ink to its bottom. Screen
// pixels are divided by the scale of a parent that would be zoomed by a transform
let width = 0;
const fit = () => {
const w = title.clientWidth;
if (!w || !glyphs.length) return;
width = w;
VARS.forEach((name) => title.style.removeProperty(name));
title.style.setProperty(VARS[0], `${REF}px`);
const style = getComputedStyle(title);
const font = `${style.fontStyle} ${style.fontWeight} ${REF}px ${style.fontFamily}`;
const marks = chars.map((char) => ink(char, font));
const scale = title.getBoundingClientRect().width / title.offsetWidth || 1;
const row = word.getBoundingClientRect();
const from = (el) => (el.getBoundingClientRect().left - row.left) / scale;
const left = from(glyphs[0]) + marks[0].left;
const right = from(glyphs.at(-1)) + marks.at(-1).right;
const baseline = (base.getBoundingClientRect().top - row.top) / scale;
const top = baseline - Math.max(...marks.map((m) => m.ascent));
const bottom = baseline + Math.max(...marks.map((m) => m.descent));
const k = w / (right - left);
[REF, bottom - top, top, left, bottom].forEach((value, i) => title.style.setProperty(VARS[i], `${value * k}px`));
};
// A new width refits on the next frame, outside the observer
let frame = 0;
const observer = new ResizeObserver(() => {
cancelAnimationFrame(frame);
frame = requestAnimationFrame(() => {
if (title.clientWidth !== width) fit();
});
});
observer.observe(title);
document.fonts?.addEventListener('loadingdone', fit, { signal });
signal.addEventListener('abort', () => {
observer.disconnect();
cancelAnimationFrame(frame);
});
fit();
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 play = async () => {
await decoded(root);
if (signal.aborted) return;
stop();
root.classList.add('is-shown');
rise(q('.kodza-hero-wordmark__eyebrow .kodza-hero-wordmark__rise'), 0, 1000);
// A long name keeps the same overall pace
const step = Math.min(70, 420 / Math.max(1, glyphs.length - 1));
glyphs.forEach((glyph, i) => rise(glyph, 120 + i * step, 1100));
// The curtain opens from the baseline down while the picture settles from a slight zoom
animate(q('.kodza-hero-wordmark__curtain'), [{ transform: 'translateY(calc(-100% - 2px))' }, { transform: 'none' }], { duration: 1350, delay: 450, easing: OPEN });
animate(q('.kodza-hero-wordmark__hold'), [{ transform: 'translateY(calc(100% + 2px))' }, { transform: 'none' }], { duration: 1350, delay: 450, easing: OPEN });
animate(q('.kodza-hero-wordmark__media img'), [{ transform: 'scale(1.2)' }, { transform: 'none' }], { duration: 2000, delay: 450, easing: SOFT });
[q('.kodza-hero-wordmark__lead'), q('.kodza-hero-wordmark__actions')].forEach((el, i) => {
animate(el, [{ opacity: 0, transform: 'translateY(20px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay: 700 + i * 110, easing: SOFT });
});
};
if (reduceMotion) {
root.classList.add('is-shown');
document.fonts?.ready.then(() => !signal.aborted && fit());
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) return;
fit();
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 Wordmark, for React. From https://kodza.dev/components/hero-wordmark/
// 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-wordmark.css and hero-wordmark.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-wordmark.css';
export type HeroWordmarkProps = Omit<ComponentPropsWithoutRef<'section'>, "children" | "vars"> & {
/** Settings, as CSS variables on the root */
vars?: {
/** default: #0a0a0a */
"--kz-hero-wordmark-ink"?: string | number;
/** default: #f2f2f0 */
"--kz-hero-wordmark-paper"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-hero-wordmark-dim"?: string | number;
/** default: rgba(10, 10, 10, 0.6) */
"--kz-hero-wordmark-faint"?: string | number;
/** default: rgba(10, 10, 10, 0.07) */
"--kz-hero-wordmark-soft"?: string | number;
/** default: transparent */
"--kz-hero-wordmark-bg"?: string | number;
/** default: none */
"--kz-hero-wordmark-width"?: string | number;
/** default: clamp(56px, 7vw, 112px) */
"--kz-hero-wordmark-pad-top"?: string | number;
/** default: clamp(16px, 4vw, 40px) */
"--kz-hero-wordmark-gutter"?: string | number;
/** default: clamp(10px, 1.2vw, 18px) */
"--kz-hero-wordmark-gap"?: string | number;
/** default: 16px */
"--kz-hero-wordmark-radius"?: string | number;
/** default: 12 / 5 */
"--kz-hero-wordmark-ratio"?: string | number;
/** default: 700 */
"--kz-hero-wordmark-weight"?: string | number;
/** default: -0.04em */
"--kz-hero-wordmark-tracking"?: string | number;
/** default: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace */
"--kz-hero-wordmark-mono"?: string | number;
/** default: cubic-bezier(0.22, 1, 0.36, 1) */
"--kz-hero-wordmark-ease"?: string | number;
};
className?: string;
};
export function HeroWordmark({ vars, className, style, ...rest }: HeroWordmarkProps) {
const ref = useRef<ComponentRef<'section'>>(null);
const classes = ["kodza-hero-wordmark", 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-wordmark.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-wordmark__inner">
<p className="kodza-hero-wordmark__eyebrow">
<span className="kodza-hero-wordmark__rise">Independent studio · Lyon, since 2019</span>
</p>
<h1 className="kodza-hero-wordmark__title">Hotfix</h1>
<p className="kodza-hero-wordmark__lead">Sites for brands that were promised one last quarter. Ours go live on a Tuesday.</p>
<div className="kodza-hero-wordmark__actions">
<a className="kodza-hero-wordmark__button kodza-hero-wordmark__button--ink" href="#">See the work<svg className="kodza-hero-wordmark__arrow" viewBox="0 0 16 16" aria-hidden="true"> <path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /> </svg></a>
{' '}
<a className="kodza-hero-wordmark__button kodza-hero-wordmark__button--soft" href="#">Book a call</a>
</div>
<div className="kodza-hero-wordmark__media">
<div className="kodza-hero-wordmark__curtain">
<div className="kodza-hero-wordmark__hold">
<img src="https://kodza.dev/media/kz-gap-2400.webp" srcSet="https://kodza.dev/media/kz-gap-1400.webp 1400w, https://kodza.dev/media/kz-gap-2400.webp 2400w" sizes="100vw" alt="A long concrete wall, split by a slot of low sun" width="2400" height="1000" fetchPriority="high" />
</div>
</div>
</div>
</div>
</section>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.