Overflow — clamp and expand
Variant: Clamp and expand
A commit body clamped to two lines, opening and closing. The second line fades out at the right rather than ending on a hard "…", so the cut reads as "continues". On press the button takes 3%, the card grows downward over 350ms on an ease-out, and the three hidden lines join 30ms apart as the edge passes them; the chevron turns with the edge, not after it. Closing runs 245ms with the lines leaving together, since an exit runs shorter than the entrance and nobody reads one. None of it touches layout: the card is a clip-path on a fixed-size sheet plus a footer that travels with the clip edge, which only works because the hard-wrapped lines give the hidden extent in exact pixels. Use it on commit messages, review comments and descriptions in a feed — wherever height is the budget and the reader decides what deserves more.
The source
A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Overflow — clamp and expand</title>
<style>
:root {
/* Neutrals — fixed, never remixed. */
--ivory: #faf9f5;
--paper: #ffffff;
--oat: #e3dacc;
--slate: #141413;
/* Knobs — the remix API. A knob exists iff declared here and used below. */
--hue: 38.8;
--lift: 0;
--chroma: 1;
--round: 1;
--speed: 1;
/* Accents — derived from the knobs with the family's offsets baked in,
so one hue roll moves them together. Defaults reproduce the original hex. */
--clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
--clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
--olive: oklch(
calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
);
--rust: oklch(
calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
);
--_muted: color-mix(in srgb, var(--slate) 52%, transparent);
/* Body lines are hard-wrapped and fixed-height, so the hidden extent is
known exactly: three lines of 18px. */
--_lh: 18px;
--_hidden: calc(var(--_lh) * 3);
/* Clock — 7s: 1% is 70ms. Opens at 18% over 350ms; closes at 66%
over 245ms, because an exit runs shorter than the entrance. */
--cycle: 7s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
display: grid;
place-items: center;
background: var(--ivory);
font-family:
system-ui,
-apple-system,
'Segoe UI',
Roboto,
sans-serif;
color: var(--slate);
}
/* The stage is sized to the open card and never resizes; the visible
card is a clip on the sheet plus a footer that travels with the clip
edge. Nothing below it reflows, and no frame touches layout. */
.stage {
position: relative;
/* Centres the closed card, the state it spends most time in; the
open card grows down into the margin. */
margin-top: var(--_hidden);
width: min(300px, calc(100vw - 32px));
height: calc(var(--_hidden) + 142px);
}
.sheet {
position: absolute;
inset: 0;
padding: 14px 16px 0;
background: var(--paper);
border: 1px solid var(--oat);
border-radius: calc(12px * var(--round));
animation: sheet var(--t) linear infinite;
}
/* The clip edge parks 12px inside the footer so the sheet's square
clipped corners always sit under the footer's rounded ones. */
@keyframes sheet {
0%,
18% {
clip-path: inset(0 0 calc(var(--_hidden) + 12px) 0);
animation-timing-function: var(--ease-out);
}
23%,
66% {
clip-path: inset(0 0 12px 0);
animation-timing-function: var(--ease-out);
}
69.5%,
100% {
clip-path: inset(0 0 calc(var(--_hidden) + 12px) 0);
}
}
.meta {
display: block;
font-size: 11.5px;
line-height: 16px;
color: var(--_muted);
font-variant-numeric: tabular-nums;
}
.subj {
display: block;
margin: 6px 0 6px;
font-size: 14px;
font-weight: 600;
line-height: 20px;
}
.body {
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
font-size: clamp(11.5px, 3.6vw, 12.5px);
line-height: var(--_lh);
white-space: nowrap;
}
.body span {
display: block;
position: relative;
height: var(--_lh);
}
/* The clamp's last visible line fades rather than ends on a hard "…",
so the cut reads as "continues" rather than "finished". */
.body .l2::after {
content: '';
position: absolute;
inset: 0 0 0 40%;
background: linear-gradient(90deg, transparent, var(--paper) 80%);
animation: veil var(--t) linear infinite;
}
@keyframes veil {
0%,
18% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
20.5%,
68.5% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
71%,
100% {
opacity: 1;
}
}
/* Hidden lines join 30ms apart as the edge passes them; on close they
leave together, since nobody reads an exit. */
.body .more {
opacity: 0;
animation: more var(--t) linear infinite;
animation-delay: calc(var(--_i) * 30ms / var(--speed));
}
@keyframes more {
0%,
18.5% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
22.5%,
66% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
68%,
100% {
opacity: 0;
}
}
.foot {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 40px;
display: flex;
align-items: center;
padding: 0 10px;
background: var(--paper);
border: 1px solid var(--oat);
border-top: 0;
border-radius: 0 0 calc(12px * var(--round)) calc(12px * var(--round));
animation: foot var(--t) linear infinite;
}
@keyframes foot {
0%,
18% {
transform: translateY(calc(var(--_hidden) * -1));
animation-timing-function: var(--ease-out);
}
23%,
66% {
transform: translateY(0);
animation-timing-function: var(--ease-out);
}
69.5%,
100% {
transform: translateY(calc(var(--_hidden) * -1));
}
}
.btn {
display: flex;
align-items: center;
gap: 5px;
height: 26px;
padding: 0 8px 0 6px;
border-radius: calc(6px * var(--round));
font-size: 12.5px;
font-weight: 600;
color: var(--clay-d);
animation: press var(--t) linear infinite;
}
@keyframes press {
0%,
15.5% {
transform: scale(1);
background: transparent;
animation-timing-function: var(--ease-out);
}
17% {
transform: scale(0.97);
background: color-mix(in srgb, var(--oat) 50%, transparent);
animation-timing-function: var(--ease-out);
}
19.5%,
63.5% {
transform: scale(1);
background: transparent;
animation-timing-function: var(--ease-out);
}
65% {
transform: scale(0.97);
background: color-mix(in srgb, var(--oat) 50%, transparent);
animation-timing-function: var(--ease-out);
}
67.5%,
100% {
transform: scale(1);
background: transparent;
}
}
.btn svg {
width: 12px;
height: 12px;
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
animation: chev var(--t) linear infinite;
}
@keyframes chev {
0%,
18% {
transform: rotate(0deg);
animation-timing-function: var(--ease-out);
}
23%,
66% {
transform: rotate(180deg);
animation-timing-function: var(--ease-out);
}
69.5%,
100% {
transform: rotate(0deg);
}
}
.label {
display: grid;
}
.label span {
grid-area: 1 / 1;
}
.lb-more {
animation: lb-more var(--t) linear infinite;
}
.lb-less {
opacity: 0;
animation: lb-less var(--t) linear infinite;
}
/* Out, then in — sequential so the two words never overlap. */
@keyframes lb-more {
0%,
18% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
19%,
67% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
68.5%,
100% {
opacity: 1;
}
}
@keyframes lb-less {
0%,
19% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
20.5%,
66% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
67%,
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.stage *,
.stage *::before,
.stage *::after {
animation-duration: calc(var(--t) * 1.6);
}
/* Same beats, no travel: the card dims, takes its new extent while
dimmed, and comes back up at full strength. */
.stage {
animation: rm-stage calc(var(--t) * 1.6) linear infinite;
}
.sheet {
animation-name: rm-sheet;
}
.foot {
animation-name: rm-foot;
}
.btn {
animation-name: none;
}
.btn svg {
animation-name: rm-chev;
}
@keyframes rm-stage {
0%,
17% {
opacity: 1;
}
19%,
20% {
opacity: 0.25;
}
23%,
65% {
opacity: 1;
}
67%,
68% {
opacity: 0.25;
}
71%,
100% {
opacity: 1;
}
}
@keyframes rm-sheet {
0%,
19.5% {
clip-path: inset(0 0 calc(var(--_hidden) + 12px) 0);
}
19.51%,
67.5% {
clip-path: inset(0 0 12px 0);
}
67.51%,
100% {
clip-path: inset(0 0 calc(var(--_hidden) + 12px) 0);
}
}
@keyframes rm-foot {
0%,
19.5% {
transform: translateY(calc(var(--_hidden) * -1));
}
19.51%,
67.5% {
transform: translateY(0);
}
67.51%,
100% {
transform: translateY(calc(var(--_hidden) * -1));
}
}
@keyframes rm-chev {
0%,
19.5% {
transform: rotate(0deg);
}
19.51%,
67.5% {
transform: rotate(180deg);
}
67.51%,
100% {
transform: rotate(0deg);
}
}
}
</style>
</head>
<body>
<div
class="stage"
role="img"
aria-label="A commit message clamped to two body lines with the second line fading out; Show more is pressed and the card grows downward to reveal three more lines, then Show less collapses it again"
>
<div class="sheet">
<span class="meta">a3f9c1e · 2h ago</span>
<span class="subj">Jitter the webhook retry backoff</span>
<div class="body">
<span>429s retried on a fixed 2s timer,</span>
<span class="l2">so every client hit us again in</span>
<span class="more" style="--_i: 0">lockstep. Backoff now doubles</span>
<span class="more" style="--_i: 1">from 500ms with ±20% jitter and</span>
<span class="more" style="--_i: 2">gives up after six attempts.</span>
</div>
</div>
<div class="foot">
<span class="btn">
<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.5 4.5 6 8l3.5-3.5" /></svg>
<span class="label">
<span class="lb-more">Show more</span>
<span class="lb-less">Show less</span>
</span>
</span>
</div>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.