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 studio hero whose headline changes one word at a time: the next word rolls up into place while a matching picture opens over the last one, in the same stroke. A ring around the pause button shows the time left.
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 Rotate to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<section class="kodza-hero-rotate" data-interval="3600">
<div class="kodza-hero-rotate__inner">
<div class="kodza-hero-rotate__head">
<p class="kodza-hero-rotate__eyebrow"><span class="kodza-hero-rotate__rise">Independent studio · Le Havre, since 2019</span></p>
<h1 class="kodza-hero-rotate__title"><span class="kodza-hero-rotate__line"><span class="kodza-hero-rotate__rise">We build <span class="kodza-hero-rotate__words"><span>sites</span><span>stores</span><span>apps</span><span>docs</span></span></span></span> <span class="kodza-hero-rotate__line"><span class="kodza-hero-rotate__rise">that ship.</span></span></h1>
</div>
<div class="kodza-hero-rotate__body">
<p class="kodza-hero-rotate__lead">Four people, no account managers. You talk to whoever writes the code, and it goes live when we said it would.</p>
<div class="kodza-hero-rotate__actions">
<a class="kodza-hero-rotate__button kodza-hero-rotate__button--ink" href="#">See the work<svg class="kodza-hero-rotate__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-rotate__button kodza-hero-rotate__button--soft" href="#">Book a call</a>
</div>
</div>
<figure class="kodza-hero-rotate__media">
<div class="kodza-hero-rotate__frame">
<div class="kodza-hero-rotate__slide"><div class="kodza-hero-rotate__curtain"><div class="kodza-hero-rotate__hold"><img src="https://kodza.dev/media/kz-steps-1400.webp" alt="A concrete staircase climbing to the right under a flat light" width="1400" height="933" /></div></div></div>
<div class="kodza-hero-rotate__slide"><div class="kodza-hero-rotate__curtain"><div class="kodza-hero-rotate__hold"><img src="https://kodza.dev/media/kz-stack-1400.webp" alt="Concrete slabs stacked in a leaning pile" width="1400" height="1050" loading="lazy" /></div></div></div>
<div class="kodza-hero-rotate__slide"><div class="kodza-hero-rotate__curtain"><div class="kodza-hero-rotate__hold"><img src="https://kodza.dev/media/kz-float-1400.webp" alt="A concrete block floating above its own shadow" width="1400" height="933" loading="lazy" /></div></div></div>
<div class="kodza-hero-rotate__slide"><div class="kodza-hero-rotate__curtain"><div class="kodza-hero-rotate__hold"><img src="https://kodza.dev/media/kz-arch-1400.webp" alt="A concrete wall with a round-topped opening, sunlight pouring through it" width="1400" height="1400" loading="lazy" /></div></div></div>
</div>
<figcaption class="kodza-hero-rotate__caption">
<span class="kodza-hero-rotate__count"><span class="kodza-hero-rotate__index"><span>01</span></span> / 04</span>
<button class="kodza-hero-rotate__pause" type="button" aria-pressed="false" aria-label="Pause the words"><svg class="kodza-hero-rotate__ring" viewBox="0 0 36 36" aria-hidden="true"><circle cx="18" cy="18" r="17" /><circle class="kodza-hero-rotate__progress" cx="18" cy="18" r="17" pathLength="100" /></svg><svg class="kodza-hero-rotate__icon" viewBox="0 0 16 16" aria-hidden="true"><path class="kodza-hero-rotate__bars" d="M5.5 4v8M10.5 4v8" /><path class="kodza-hero-rotate__play" d="M5.5 3.8v8.4L12 8z" /></svg></button>
</figcaption>
</figure>
</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 Rotate
A studio hero whose headline keeps changing one word: the next word rolls up into place as the
old one leaves, and the picture beside it opens from the top edge in the same stroke, one
picture per word. A ring around the pause button shows the time left; it waits while the
picture is hovered, the hero holds the focus or is out of view.
Everything is tuned with the --kz-hero-rotate-* variables (and data-interval, in ms). */
.kodza-hero-rotate {
--kz-hero-rotate-ink: #0a0a0a;
--kz-hero-rotate-paper: #f2f2f0;
--kz-hero-rotate-dim: rgba(10, 10, 10, 0.62);
--kz-hero-rotate-faint: rgba(10, 10, 10, 0.6);
--kz-hero-rotate-soft: rgba(10, 10, 10, 0.07);
--kz-hero-rotate-track: rgba(10, 10, 10, 0.14);
--kz-hero-rotate-bg: transparent;
--kz-hero-rotate-width: 1240px;
--kz-hero-rotate-gap: clamp(32px, 5vw, 80px);
--kz-hero-rotate-pad-y: clamp(72px, 9vw, 140px);
--kz-hero-rotate-gutter: clamp(16px, 4vw, 40px);
--kz-hero-rotate-radius: 16px;
--kz-hero-rotate-ratio: 3 / 2;
--kz-hero-rotate-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
--kz-hero-rotate-ease: cubic-bezier(0.22, 1, 0.36, 1);
container: kodza-hero-rotate / inline-size;
box-sizing: border-box;
width: 100%;
padding-block: var(--kz-hero-rotate-pad-y);
padding-left: max(var(--kz-hero-rotate-gutter), env(safe-area-inset-left, 0px));
padding-right: max(var(--kz-hero-rotate-gutter), env(safe-area-inset-right, 0px));
background: var(--kz-hero-rotate-bg);
color: var(--kz-hero-rotate-ink);
}
/* The headline across the top, then the words on the left and the picture on the right */
.kodza-hero-rotate__inner {
display: grid;
grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
grid-template-areas:
"head head"
"body media";
column-gap: var(--kz-hero-rotate-gap);
row-gap: clamp(28px, 3.6vw, 52px);
max-width: var(--kz-hero-rotate-width);
margin: 0 auto;
}
.kodza-hero-rotate__head {
grid-area: head;
min-width: 0;
}
.kodza-hero-rotate__body {
grid-area: body;
min-width: 0;
}
.kodza-hero-rotate__eyebrow {
margin: 0 0 22px;
overflow: hidden;
font-family: var(--kz-hero-rotate-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-rotate-faint);
}
.kodza-hero-rotate__title {
margin: 0;
/* Bounded by the container too, so the longest word keeps its line on a phone */
font-size: min(clamp(42px, 8vw, 120px), 12.4cqi);
font-weight: 700;
line-height: 1;
letter-spacing: -0.05em;
color: var(--kz-hero-rotate-ink);
}
/* Each line is its own mask: the words rise from behind its bottom edge */
.kodza-hero-rotate__line {
display: block;
overflow: hidden;
padding-bottom: 0.08em;
margin-bottom: -0.08em;
}
.kodza-hero-rotate__rise {
display: block;
}
/* The changing word: a window as tall as its letters, clipped without leaving the line */
.kodza-hero-rotate__words {
display: inline-grid;
overflow: clip;
padding-block: 0.08em 0.14em;
margin-block: -0.08em -0.14em;
line-height: 1;
vertical-align: baseline;
white-space: nowrap;
}
.kodza-hero-rotate__words > span {
grid-area: 1 / 1;
justify-self: start;
}
/* Without the script, the first word alone */
.kodza-hero-rotate:not(.is-live) .kodza-hero-rotate__words > span + span {
display: none;
}
.kodza-hero-rotate__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
white-space: nowrap;
}
.kodza-hero-rotate__lead {
max-width: 34ch;
margin: 0 0 36px;
font-size: clamp(17px, 1.45vw, 20px);
line-height: 1.55;
color: var(--kz-hero-rotate-dim);
text-wrap: pretty;
}
.kodza-hero-rotate__actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.kodza-hero-rotate__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-rotate__button:focus-visible,
.kodza-hero-rotate__pause:focus-visible {
outline: 2px solid var(--kz-hero-rotate-ink);
outline-offset: 3px;
}
/* Solid: the arrow steps forward on hover */
.kodza-hero-rotate__button--ink {
background: var(--kz-hero-rotate-ink);
color: var(--kz-hero-rotate-paper);
}
.kodza-hero-rotate__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-rotate-ease);
}
/* Soft: ink rises from the bottom edge on hover */
.kodza-hero-rotate__button--soft {
background: var(--kz-hero-rotate-soft);
color: var(--kz-hero-rotate-ink);
transition: color 0.4s var(--kz-hero-rotate-ease);
}
.kodza-hero-rotate__button--soft::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: var(--kz-hero-rotate-ink);
transform: translateY(101%);
transition: transform 0.4s var(--kz-hero-rotate-ease);
}
@media (hover: hover) {
.kodza-hero-rotate__button--ink:hover .kodza-hero-rotate__arrow {
transform: translateX(4px);
}
.kodza-hero-rotate__button--soft:hover {
color: var(--kz-hero-rotate-paper);
}
.kodza-hero-rotate__button--soft:hover::before {
transform: none;
}
}
.kodza-hero-rotate__media {
grid-area: media;
min-width: 0;
margin: 0;
}
/* The pictures sit on top of each other; the next one opens over the last */
.kodza-hero-rotate__frame {
position: relative;
isolation: isolate;
max-width: 100%;
aspect-ratio: var(--kz-hero-rotate-ratio);
overflow: hidden;
border-radius: var(--kz-hero-rotate-radius);
}
.kodza-hero-rotate__slide {
position: absolute;
inset: 0;
}
.kodza-hero-rotate__slide + .kodza-hero-rotate__slide {
visibility: hidden;
}
.kodza-hero-rotate.is-live .kodza-hero-rotate__slide {
visibility: hidden;
}
.kodza-hero-rotate.is-live .kodza-hero-rotate__slide.is-current,
.kodza-hero-rotate.is-live .kodza-hero-rotate__slide.is-leaving {
visibility: visible;
}
.kodza-hero-rotate.is-live .kodza-hero-rotate__slide.is-current {
z-index: 1;
}
/* 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-rotate__curtain,
.kodza-hero-rotate__hold {
height: 100%;
}
.kodza-hero-rotate__curtain {
overflow: hidden;
}
.kodza-hero-rotate__frame img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
/* Under the picture: which one it is, and the pause button with the time left around it */
.kodza-hero-rotate__caption {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-top: 12px;
font-family: var(--kz-hero-rotate-mono);
font-size: 12.5px;
line-height: 16px;
color: var(--kz-hero-rotate-faint);
}
.kodza-hero-rotate__count {
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.kodza-hero-rotate__index {
display: inline-grid;
overflow: clip;
vertical-align: top;
}
.kodza-hero-rotate__index > span {
grid-area: 1 / 1;
}
.kodza-hero-rotate__pause {
position: relative;
flex: none;
display: grid;
place-items: center;
width: 36px;
height: 36px;
margin: 0;
padding: 0;
border: 0;
border-radius: 50%;
background: transparent;
color: var(--kz-hero-rotate-ink);
cursor: pointer;
}
/* Nothing to pause until the words turn */
.kodza-hero-rotate:not(.is-live) .kodza-hero-rotate__pause {
visibility: hidden;
}
.kodza-hero-rotate__ring,
.kodza-hero-rotate__icon {
grid-area: 1 / 1;
}
.kodza-hero-rotate__ring {
width: 36px;
height: 36px;
fill: none;
stroke: var(--kz-hero-rotate-track);
stroke-width: 1.5;
transform: rotate(-90deg);
}
.kodza-hero-rotate__progress {
stroke: var(--kz-hero-rotate-ink);
stroke-dasharray: 100;
stroke-dashoffset: 100;
}
.kodza-hero-rotate__icon {
width: 14px;
height: 14px;
fill: none;
stroke: currentColor;
stroke-width: 1.6;
stroke-linecap: round;
stroke-linejoin: round;
}
.kodza-hero-rotate__play {
fill: currentColor;
stroke-width: 1.2;
opacity: 0;
transform: scale(0.6);
transform-origin: 50% 50%;
transition: opacity 0.2s, transform 0.25s var(--kz-hero-rotate-ease);
}
.kodza-hero-rotate__bars {
transform-origin: 50% 50%;
transition: opacity 0.2s, transform 0.25s var(--kz-hero-rotate-ease);
}
.kodza-hero-rotate__pause[aria-pressed="true"] .kodza-hero-rotate__bars {
opacity: 0;
transform: scale(0.6);
}
.kodza-hero-rotate__pause[aria-pressed="true"] .kodza-hero-rotate__play {
opacity: 1;
transform: none;
}
/* 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-rotate.is-ready:not(.is-shown) .kodza-hero-rotate__rise {
transform: translateY(105%);
}
.kodza-hero-rotate.is-ready:not(.is-shown) .kodza-hero-rotate__curtain {
transform: translateY(-100%);
}
.kodza-hero-rotate.is-ready:not(.is-shown) .kodza-hero-rotate__hold {
transform: translateY(100%);
}
.kodza-hero-rotate.is-ready:not(.is-shown) .kodza-hero-rotate__lead,
.kodza-hero-rotate.is-ready:not(.is-shown) .kodza-hero-rotate__actions,
.kodza-hero-rotate.is-ready:not(.is-shown) .kodza-hero-rotate__caption {
opacity: 0;
transform: translateY(20px);
}
}
/* One column: the picture goes under the words and the buttons share the row */
@container kodza-hero-rotate (max-width: 700px) {
.kodza-hero-rotate__inner {
grid-template-columns: minmax(0, 1fr);
grid-template-areas:
"head"
"body"
"media";
}
.kodza-hero-rotate__button {
flex: 1 1 auto;
justify-content: center;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-rotate *,
.kodza-hero-rotate *::before,
.kodza-hero-rotate *::after {
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
}
}
/* kodza-guard b91d7ef6ec23 — 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-rotate__eyebrow):not(#_),
:where(.kodza-hero-rotate__title):not(#_),
:where(.kodza-hero-rotate__lead):not(#_),
:where(.kodza-hero-rotate__media):not(#_),
:where(.kodza-hero-rotate__caption):not(#_),
:where(.kodza-hero-rotate__ring):not(#_),
:where(.kodza-hero-rotate__icon):not(#_),
:where(.kodza-hero-rotate__hold img:where(:not([class*="kodza-"]))):not(#_) {
transition-duration: revert;
}
:where(.kodza-hero-rotate__button):not(#_) {
outline: revert;
transition: revert;
outline-offset: revert;
}
:where(.kodza-hero-rotate__pause):not(#_) {
outline: revert;
outline-offset: revert;
transition-duration: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-hero-rotate__inner:not(#_),
.kodza-hero-rotate__head:not(#_),
.kodza-hero-rotate__rise:not(#_),
.kodza-hero-rotate__line:not(#_),
.kodza-hero-rotate__words:not(#_),
.kodza-hero-rotate__word:not(#_),
.kodza-hero-rotate__sr:not(#_),
.kodza-hero-rotate__body:not(#_),
.kodza-hero-rotate__actions:not(#_),
.kodza-hero-rotate__frame:not(#_),
.kodza-hero-rotate__slide:not(#_),
.kodza-hero-rotate__curtain:not(#_),
.kodza-hero-rotate__hold:not(#_),
.kodza-hero-rotate__count:not(#_),
.kodza-hero-rotate__index:not(#_),
.kodza-hero-rotate__progress:not(#_),
.kodza-hero-rotate__bars:not(#_),
.kodza-hero-rotate__play:not(#_),
.kodza-hero-rotate__index span:where(:not([class*="kodza-"])):not(#_) {
box-sizing: revert;
}
.kodza-hero-rotate__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-rotate__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-rotate__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-rotate__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-rotate__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-rotate__media: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;
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-rotate__caption:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
margin-right: revert;
margin-bottom: revert;
margin-left: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: 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-rotate__pause:not(#_) {
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: 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;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
white-space: revert;
min-height: revert;
}
.kodza-hero-rotate__ring:not(#_),
.kodza-hero-rotate__icon:not(#_),
.kodza-hero-rotate__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-rotate__eyebrow:not(#_):where(:not([hidden])),
.kodza-hero-rotate__title:not(#_):where(:not([hidden])),
.kodza-hero-rotate__lead:not(#_):where(:not([hidden])),
.kodza-hero-rotate__arrow:not(#_):where(:not([hidden])),
.kodza-hero-rotate__media:not(#_):where(:not([hidden])),
.kodza-hero-rotate__ring:not(#_):where(:not([hidden])),
.kodza-hero-rotate__icon:not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-hero-rotate__eyebrow:not(#_):where([hidden]),
.kodza-hero-rotate__title:not(#_):where([hidden]),
.kodza-hero-rotate__lead:not(#_):where([hidden]),
.kodza-hero-rotate__arrow:not(#_):where([hidden]),
.kodza-hero-rotate__media:not(#_):where([hidden]),
.kodza-hero-rotate__ring:not(#_):where([hidden]),
.kodza-hero-rotate__icon: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-rotate__eyebrow:not(#_) {
margin: 0 0 22px;
font-family: var(--kz-hero-rotate-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-rotate-faint);
}
.kodza-hero-rotate__title:not(#_) {
margin: 0;
font-size: min(clamp(42px, 8vw, 120px), 12.4cqi);
font-weight: 700;
line-height: 1;
letter-spacing: -0.05em;
color: var(--kz-hero-rotate-ink);
}
.kodza-hero-rotate__lead:not(#_) {
max-width: 34ch;
margin: 0 0 36px;
font-size: clamp(17px, 1.45vw, 20px);
line-height: 1.55;
color: var(--kz-hero-rotate-dim);
}
.kodza-hero-rotate__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-rotate__button:focus-visible:not(#_) {
outline: 2px solid var(--kz-hero-rotate-ink);
outline-offset: 3px;
}
.kodza-hero-rotate__pause:focus-visible:not(#_) {
outline: 2px solid var(--kz-hero-rotate-ink);
outline-offset: 3px;
}
.kodza-hero-rotate__button--ink:not(#_) {
background: var(--kz-hero-rotate-ink);
color: var(--kz-hero-rotate-paper);
}
.kodza-hero-rotate__arrow:not(#_) {
transition: transform 0.3s var(--kz-hero-rotate-ease);
}
.kodza-hero-rotate__button--soft:not(#_) {
background: var(--kz-hero-rotate-soft);
color: var(--kz-hero-rotate-ink);
transition: color 0.4s var(--kz-hero-rotate-ease);
}
@media (hover: hover) {
.kodza-hero-rotate__button--soft:hover:not(#_) {
color: var(--kz-hero-rotate-paper);
}
}
.kodza-hero-rotate__media:not(#_) {
margin: 0;
}
.kodza-hero-rotate__frame img:not(#_) {
display: block;
}
.kodza-hero-rotate__caption:not(#_) {
display: flex;
margin-top: 12px;
font-family: var(--kz-hero-rotate-mono);
font-size: 12.5px;
line-height: 16px;
color: var(--kz-hero-rotate-faint);
}
.kodza-hero-rotate__pause:not(#_) {
position: relative;
flex: none;
display: grid;
place-items: center;
width: 36px;
height: 36px;
margin: 0;
padding: 0;
border: 0;
border-radius: 50%;
background: transparent;
color: var(--kz-hero-rotate-ink);
cursor: pointer;
}
.kodza-hero-rotate:not(.is-live) .kodza-hero-rotate__pause:not(#_) {
visibility: hidden;
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-rotate *:not(#_),
.kodza-hero-rotate *:not(#_)::before,
.kodza-hero-rotate *:not(#_)::after {
transition-duration: 0.01ms !important;
animation-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 Rotate
// Plays the Hero Split entrance once the section is in view, its picture decoded and the fonts
// in, then turns the words: the next word rolls up into place as the old one leaves through the
// top, and the matching picture opens from the top edge over the last one, with the same timing
// and curve, while the count rolls with them. The ring around the pause button fills until the next
// word; it waits while the picture is hovered, a link in the hero has the focus, the hero is out
// of view or the tab hidden. With reduced motion, the first word and picture simply stay.
// "kodza:replay" plays the entrance again from the first word.
(() => {
const SELECTOR = '.kodza-hero-rotate';
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 TURN = 1200; // one stroke: the word, the picture, the count and the ring move together
const decoded = (root) => Promise.all([...root.querySelectorAll('img')].slice(0, 1).map((img) => img.decode().catch(() => {})));
const pad = (n) => String(n).padStart(2, '0');
// 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) {
if (reduceMotion) return root.classList.add('is-shown');
const q = (s) => root.querySelector(s);
const slot = q('.kodza-hero-rotate__words');
const slides = [...root.querySelectorAll('.kodza-hero-rotate__slide')];
const words = slot ? [...slot.children].map((el) => el.textContent) : [];
const count = q('.kodza-hero-rotate__index');
const button = q('.kodza-hero-rotate__pause');
const progress = q('.kodza-hero-rotate__progress');
const interval = parseInt(root.dataset.interval, 10) || 3600;
const turns = words.length > 1;
let entrance = [];
let motion = [];
let index = 0;
let ring = [];
let timer = null;
let rounds = 0;
let started = 0;
let visible = false;
let hovered = false;
let focused = false;
let held = false;
const stop = (list) => {
list.forEach((a) => a.cancel());
list.length = 0;
};
const animate = (list, el, keyframes, options) => {
if (!el) return null;
const animation = el.animate(keyframes, { easing: GLIDE, fill: 'backwards', ...options });
list.push(animation);
return animation;
};
// The word: screen readers get every word once, the turning one is for the eyes
const make = (text) => Object.assign(document.createElement('span'), { className: 'kodza-hero-rotate__word', textContent: text });
if (turns) {
const sr = Object.assign(document.createElement('span'), { className: 'kodza-hero-rotate__sr', textContent: words.join(', ') });
slot.after(sr);
slot.setAttribute('aria-hidden', 'true');
root.classList.add('is-live');
}
const roll = (text) => {
if (!count) return;
const old = count.lastElementChild;
const digits = Object.assign(document.createElement('span'), { textContent: text });
count.append(digits);
animate(motion, old, [{ transform: 'none' }, { transform: 'translateY(-100%)' }], { duration: TURN, fill: 'forwards' })?.finished.then(() => old.remove(), () => {});
animate(motion, digits, [{ transform: 'translateY(100%)' }, { transform: 'none' }], { duration: TURN });
};
// Back to the first word and picture, without motion
const reset = () => {
stop(motion);
index = 0;
if (!turns) return;
slot.replaceChildren(make(words[0]));
slides.forEach((slide, i) => {
slide.classList.toggle('is-current', i === 0);
slide.classList.remove('is-leaving');
});
if (count) count.replaceChildren(Object.assign(document.createElement('span'), { textContent: '01' }));
};
const next = async (round) => {
const from = index;
const to = (index + 1) % words.length;
const coming = slides[to % slides.length];
const leaving = slides[from % slides.length];
// The picture is ready before anything moves, so the word never runs ahead of it
await coming?.querySelector('img')?.decode().catch(() => {});
if (round !== rounds) return;
index = to;
const old = slot.lastElementChild;
const word = make(words[to]);
const width = slot.offsetWidth;
slot.append(word);
// The two words roll up together, like a strip, while the slot eases to the new width;
// the old word and the held width go in the same task, so the slot never flashes wider
const sized = animate(motion, slot, [{ width: `${width}px` }, { width: `${word.offsetWidth}px` }], { duration: TURN, fill: 'forwards' });
animate(motion, old, [{ transform: 'none' }, { transform: 'translateY(-120%)' }], { duration: TURN, fill: 'forwards' }).finished.then(() => {
old.remove();
sized.cancel();
}, () => {});
animate(motion, word, [{ transform: 'translateY(120%)' }, { transform: 'none' }], { duration: TURN });
roll(pad(to + 1));
if (coming && coming !== leaving) {
leaving.classList.remove('is-current');
leaving.classList.add('is-leaving');
coming.classList.add('is-current');
// The new picture opens from the top edge in the same stroke as the word; the last one
// sinks a little under it
const opened = animate(motion, coming.querySelector('.kodza-hero-rotate__curtain'), [{ transform: 'translateY(-100%)' }, { transform: 'none' }], { duration: TURN });
animate(motion, coming.querySelector('.kodza-hero-rotate__hold'), [{ transform: 'translateY(100%)' }, { transform: 'none' }], { duration: TURN });
animate(motion, coming.querySelector('img'), [{ transform: 'scale(1.2)' }, { transform: 'none' }], { duration: TURN * 1.5, easing: SOFT });
const sink = animate(motion, leaving.querySelector('.kodza-hero-rotate__hold'), [{ transform: 'none' }, { transform: 'translateY(14%)' }], { duration: TURN, fill: 'forwards' });
opened.finished.then(() => {
leaving.classList.remove('is-leaving');
sink.cancel();
}, () => {});
}
// The next picture starts loading now, well before its turn
slides[(to + 1) % slides.length]?.querySelector('img')?.decode().catch(() => {});
};
// The timer is the ring itself: it fills over the interval, then empties forward as the
// word turns. It holds whenever something asks it to wait.
const waiting = () => held || hovered || focused || !visible || document.hidden;
const sync = () => {
if (!timer) return;
if (waiting()) timer.pause();
else timer.play();
};
const tick = (round) => {
const filled = progress.animate([{ strokeDashoffset: 100 }, { strokeDashoffset: 0 }], { duration: interval, easing: 'linear', fill: 'forwards' });
timer = filled;
sync();
filled.finished.then(() => {
if (round !== rounds) return;
timer = null;
next(round);
const emptied = progress.animate([{ strokeDashoffset: 0 }, { strokeDashoffset: -100 }], { duration: TURN, easing: GLIDE, fill: 'forwards' });
ring.push(filled, emptied);
emptied.finished.then(() => {
stop(ring);
if (round === rounds) tick(round);
}, () => {});
}, () => {});
};
const halt = () => {
rounds += 1;
timer?.cancel();
timer = null;
stop(ring);
clearTimeout(started);
};
const play = async () => {
await decoded(root);
if (signal.aborted) return;
stop(entrance);
halt();
reset();
root.classList.add('is-shown');
const rise = (el, delay, duration) => animate(entrance, el, [{ transform: 'translateY(105%)' }, { transform: 'none' }], { duration, delay });
rise(q('.kodza-hero-rotate__eyebrow .kodza-hero-rotate__rise'), 0, 1000);
root.querySelectorAll('.kodza-hero-rotate__line .kodza-hero-rotate__rise').forEach((line, i) => rise(line, 110 + i * 125, 1170));
// The curtain: both layers on transforms, the picture settles from a slight zoom
const first = slides[0];
animate(entrance, first?.querySelector('.kodza-hero-rotate__curtain'), [{ transform: 'translateY(-100%)' }, { transform: 'none' }], { duration: 1350, delay: 200 });
animate(entrance, first?.querySelector('.kodza-hero-rotate__hold'), [{ transform: 'translateY(100%)' }, { transform: 'none' }], { duration: 1350, delay: 200 });
animate(entrance, first?.querySelector('img'), [{ transform: 'scale(1.2)' }, { transform: 'none' }], { duration: 2000, delay: 200, easing: SOFT });
[q('.kodza-hero-rotate__lead'), q('.kodza-hero-rotate__actions')].forEach((el, i) => {
animate(entrance, el, [{ opacity: 0, transform: 'translateY(20px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay: 700 + i * 110, easing: SOFT });
});
// The faint caption is fully there halfway up: never read half-faded
animate(entrance, q('.kodza-hero-rotate__caption'), [{ opacity: 0, transform: 'translateY(20px)' }, { opacity: 1, offset: 0.5 }, { opacity: 1, transform: 'none' }], { duration: 900, delay: 920, easing: SOFT });
// The words start turning once the picture has opened
const round = rounds;
if (turns && progress) started = setTimeout(() => tick(round), 1550);
slides[1]?.querySelector('img')?.decode().catch(() => {});
};
reset();
button?.addEventListener('click', () => {
held = !held;
button.setAttribute('aria-pressed', String(held));
sync();
}, { signal });
const media = q('.kodza-hero-rotate__frame');
media?.addEventListener('pointerenter', (event) => {
if (event.pointerType !== 'mouse') return;
hovered = true;
sync();
}, { signal });
media?.addEventListener('pointerleave', () => {
hovered = false;
sync();
}, { signal });
// A link reached with the keyboard holds the words; the pause button has its own say
root.addEventListener('focusin', (event) => {
focused = event.target !== button && event.target.matches(':focus-visible');
sync();
}, { signal });
root.addEventListener('focusout', (event) => {
if (!root.contains(event.relatedTarget)) focused = false;
sync();
}, { signal });
document.addEventListener('visibilitychange', sync, { signal });
root.addEventListener('kodza:replay', play, { signal });
signal.addEventListener('abort', () => {
stop(entrance);
stop(motion);
halt();
});
const seen = new IntersectionObserver(([entry]) => {
visible = entry.isIntersecting;
sync();
});
seen.observe(root);
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();
seen.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 Rotate, for React. From https://kodza.dev/components/hero-rotate/
// 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-rotate.css and hero-rotate.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-rotate.css';
export type HeroRotateProps = Omit<ComponentPropsWithoutRef<'section'>, "children" | "vars" | "interval"> & {
/** data-interval on the root (default: 3600) */
interval?: "3600";
/** Settings, as CSS variables on the root */
vars?: {
/** default: #0a0a0a */
"--kz-hero-rotate-ink"?: string | number;
/** default: #f2f2f0 */
"--kz-hero-rotate-paper"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-hero-rotate-dim"?: string | number;
/** default: rgba(10, 10, 10, 0.6) */
"--kz-hero-rotate-faint"?: string | number;
/** default: rgba(10, 10, 10, 0.07) */
"--kz-hero-rotate-soft"?: string | number;
/** default: rgba(10, 10, 10, 0.14) */
"--kz-hero-rotate-track"?: string | number;
/** default: transparent */
"--kz-hero-rotate-bg"?: string | number;
/** default: 1240px */
"--kz-hero-rotate-width"?: string | number;
/** default: clamp(32px, 5vw, 80px) */
"--kz-hero-rotate-gap"?: string | number;
/** default: clamp(72px, 9vw, 140px) */
"--kz-hero-rotate-pad-y"?: string | number;
/** default: clamp(16px, 4vw, 40px) */
"--kz-hero-rotate-gutter"?: string | number;
/** default: 16px */
"--kz-hero-rotate-radius"?: string | number;
/** default: 3 / 2 */
"--kz-hero-rotate-ratio"?: string | number;
/** default: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace */
"--kz-hero-rotate-mono"?: string | number;
/** default: cubic-bezier(0.22, 1, 0.36, 1) */
"--kz-hero-rotate-ease"?: string | number;
};
className?: string;
};
export function HeroRotate({ interval = "3600", vars, className, style, ...rest }: HeroRotateProps) {
const ref = useRef<ComponentRef<'section'>>(null);
const classes = ["kodza-hero-rotate", 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, interval, 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-rotate.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} data-interval={interval} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<div className="kodza-hero-rotate__inner">
<div className="kodza-hero-rotate__head">
<p className="kodza-hero-rotate__eyebrow">
<span className="kodza-hero-rotate__rise">Independent studio · Le Havre, since 2019</span>
</p>
<h1 className="kodza-hero-rotate__title">
<span className="kodza-hero-rotate__line">
<span className="kodza-hero-rotate__rise">We build <span className="kodza-hero-rotate__words"> <span>sites</span> <span>stores</span> <span>apps</span> <span>docs</span> </span></span>
</span>
{' '}
<span className="kodza-hero-rotate__line">
<span className="kodza-hero-rotate__rise">that ship.</span>
</span>
</h1>
</div>
<div className="kodza-hero-rotate__body">
<p className="kodza-hero-rotate__lead">Four people, no account managers. You talk to whoever writes the code, and it goes live when we said it would.</p>
<div className="kodza-hero-rotate__actions">
<a className="kodza-hero-rotate__button kodza-hero-rotate__button--ink" href="#">See the work<svg className="kodza-hero-rotate__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-rotate__button kodza-hero-rotate__button--soft" href="#">Book a call</a>
</div>
</div>
<figure className="kodza-hero-rotate__media">
<div className="kodza-hero-rotate__frame">
<div className="kodza-hero-rotate__slide">
<div className="kodza-hero-rotate__curtain">
<div className="kodza-hero-rotate__hold">
<img src="https://kodza.dev/media/kz-steps-1400.webp" alt="A concrete staircase climbing to the right under a flat light" width="1400" height="933" />
</div>
</div>
</div>
<div className="kodza-hero-rotate__slide">
<div className="kodza-hero-rotate__curtain">
<div className="kodza-hero-rotate__hold">
<img src="https://kodza.dev/media/kz-stack-1400.webp" alt="Concrete slabs stacked in a leaning pile" width="1400" height="1050" loading="lazy" />
</div>
</div>
</div>
<div className="kodza-hero-rotate__slide">
<div className="kodza-hero-rotate__curtain">
<div className="kodza-hero-rotate__hold">
<img src="https://kodza.dev/media/kz-float-1400.webp" alt="A concrete block floating above its own shadow" width="1400" height="933" loading="lazy" />
</div>
</div>
</div>
<div className="kodza-hero-rotate__slide">
<div className="kodza-hero-rotate__curtain">
<div className="kodza-hero-rotate__hold">
<img src="https://kodza.dev/media/kz-arch-1400.webp" alt="A concrete wall with a round-topped opening, sunlight pouring through it" width="1400" height="1400" loading="lazy" />
</div>
</div>
</div>
</div>
<figcaption className="kodza-hero-rotate__caption">
<span className="kodza-hero-rotate__count"><span className="kodza-hero-rotate__index"> <span>01</span> </span> / 04</span>
{' '}
<button className="kodza-hero-rotate__pause" type="button" aria-pressed="false" aria-label="Pause the words">
<svg className="kodza-hero-rotate__ring" viewBox="0 0 36 36" aria-hidden="true">
<circle cx="18" cy="18" r="17" />
<circle className="kodza-hero-rotate__progress" cx="18" cy="18" r="17" pathLength="100" />
</svg>
<svg className="kodza-hero-rotate__icon" viewBox="0 0 16 16" aria-hidden="true">
<path className="kodza-hero-rotate__bars" d="M5.5 4v8M10.5 4v8" />
<path className="kodza-hero-rotate__play" d="M5.5 3.8v8.4L12 8z" />
</svg>
</button>
</figcaption>
</figure>
</div>
</section>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.