Overflow — truncate the middle
Variant: Truncate the middle
Three file names that only differ at the end, cut the default way: `text-overflow: ellipsis` keeps the first nineteen characters and drops the ending, so every row reads "launch-plan-review-…" and the list is useless. The fix plays out in place. The end ellipsis and the shared middle drop out in 120ms, and while they are still fading each distinguishing tail is pulled in from beyond the edge on a 420ms ease-in-out — it is being moved, not arriving — so there is never an empty beat; a muted "…" lands where the middle was. Rows follow 40ms apart, and the kept head greys back once it stops being what tells the rows apart. Monospace makes every offset a whole number of characters, so the resting states land on exact glyph boundaries. Reach for middle truncation on file names, branch names, URLs and IDs: anything where the end carries the meaning. The reset happens in a dark window at the wrap, longer than the row stagger, because playing the fix backwards would teach the wrong lesson.
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 — truncate the middle</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) 50%, transparent);
/* Clock — 6s: 1% is 60ms. End-cut holds to 34%, the tail is pulled in
by 42%, and the caption lands on the result at 46%. */
--cycle: 6s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 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);
}
.card {
width: min(280px, calc(100vw - 32px));
padding: 14px 16px 14px;
display: grid;
gap: 8px;
border-radius: calc(12px * var(--round));
background: var(--paper);
border: 1px solid var(--oat);
animation: card var(--t) linear infinite;
}
/* Middle-cut back to end-cut would teach the wrong lesson, so the reset
happens in a dark window at the wrap instead of on screen. */
/* The dark window outlasts the 80ms row stagger, so the last row has
reset before the card comes back up. */
@keyframes card {
0%,
4% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
6.5% {
opacity: 1;
}
95.5% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
100% {
opacity: 0;
}
}
.k {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--_muted);
}
ul {
list-style: none;
}
li {
--_d: calc(var(--_i) * 40ms / var(--speed));
display: flex;
align-items: center;
gap: 8px;
height: 30px;
border-top: 1px solid var(--oat);
}
li svg {
flex: none;
width: 14px;
height: 14px;
fill: none;
stroke: var(--_muted);
stroke-width: 1.6;
stroke-linejoin: round;
}
/* Monospace, untracked, so 1ch is one glyph and every offset below is a
whole number of characters. The window is 20ch: 19 glyphs and a cut. */
.win {
position: relative;
width: 20ch;
overflow: hidden;
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
font-size: clamp(12px, 3.8vw, 13px);
white-space: nowrap;
}
.name {
display: flex;
}
.head,
.mid,
.tail,
.end,
.dots {
animation-duration: var(--t);
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-delay: var(--_d);
}
.head {
animation-name: head;
}
.mid {
animation-name: gone;
}
.tail {
animation-name: tail;
}
.end {
position: absolute;
top: 0;
right: 0;
width: 1ch;
background: var(--paper);
animation-name: gone;
}
.dots {
position: absolute;
top: 0;
left: 7ch;
color: var(--_muted);
opacity: 0;
animation-name: dots;
}
/* The kept head recedes once it stops being what tells rows apart. */
@keyframes head {
0%,
40% {
color: var(--slate);
animation-timing-function: ease;
}
44%,
100% {
color: var(--_muted);
}
}
@keyframes gone {
0%,
34% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
36%,
100% {
opacity: 0;
}
}
/* 25ch to 8ch, starting while the middle is still fading so there is
no empty beat. Already on screen in principle, so ease-in-out: it is
being moved, not arriving. */
@keyframes tail {
0%,
35% {
transform: translateX(0);
animation-timing-function: var(--ease-in-out);
}
42%,
100% {
transform: translateX(-17ch);
}
}
@keyframes dots {
0%,
41% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
43%,
100% {
opacity: 1;
}
}
.note {
display: grid;
padding-top: 2px;
font-size: 12px;
line-height: 1.4;
}
.note span {
grid-area: 1 / 1;
}
.n-a {
color: var(--clay-d);
animation: n-out var(--t) linear infinite;
}
.n-b {
color: var(--olive);
opacity: 0;
animation: n-in var(--t) linear infinite;
}
@keyframes n-out {
0%,
33% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
35%,
100% {
opacity: 0;
}
}
@keyframes n-in {
0%,
43% {
opacity: 0;
transform: translateY(3px);
animation-timing-function: var(--ease-out);
}
47%,
100% {
opacity: 1;
transform: translateY(0);
}
}
@media (prefers-reduced-motion: reduce) {
.card,
.card *,
.card *::before,
.card *::after {
animation-duration: calc(var(--t) * 1.6);
}
/* Same beats; the tail fades out, jumps, and fades back in. */
.tail {
animation-name: rm-tail;
}
.n-b {
animation-name: rm-in;
transform: none;
}
@keyframes rm-tail {
0%,
34% {
opacity: 1;
transform: translateX(0);
}
36% {
opacity: 0;
transform: translateX(0);
}
36.01% {
opacity: 0;
transform: translateX(-17ch);
}
41%,
100% {
opacity: 1;
transform: translateX(-17ch);
}
}
@keyframes rm-in {
0%,
43% {
opacity: 0;
}
47%,
100% {
opacity: 1;
}
}
}
</style>
</head>
<body>
<div
class="card"
role="img"
aria-label="Three file names that differ only at the end are cut off with an end ellipsis and look identical; then the middle collapses into an ellipsis and each distinguishing ending slides into view"
>
<span class="k">Recent files</span>
<ul>
<li style="--_i: 0">
<svg viewBox="0 0 16 16" aria-hidden="true">
<path d="M4 1.8h5.2L12.5 5v9.2H4z M9 1.8V5.3h3.5" />
</svg>
<span class="win"
><span class="name"
><span class="head">launch-</span><span class="mid">plan-review-notes-</span
><span class="tail">draft.md</span></span
><span class="end">…</span><span class="dots">…</span></span
>
</li>
<li style="--_i: 1">
<svg viewBox="0 0 16 16" aria-hidden="true">
<path d="M4 1.8h5.2L12.5 5v9.2H4z M9 1.8V5.3h3.5" />
</svg>
<span class="win"
><span class="name"
><span class="head">launch-</span><span class="mid">plan-review-notes-</span
><span class="tail">final.md</span></span
><span class="end">…</span><span class="dots">…</span></span
>
</li>
<li style="--_i: 2">
<svg viewBox="0 0 16 16" aria-hidden="true">
<path d="M4 1.8h5.2L12.5 5v9.2H4z M9 1.8V5.3h3.5" />
</svg>
<span class="win"
><span class="name"
><span class="head">launch-</span><span class="mid">plan-review-notes-</span
><span class="tail">final-v2.md</span></span
><span class="end">…</span><span class="dots">…</span></span
>
</li>
</ul>
<p class="note">
<span class="n-a">Cut at the end: three identical rows</span>
<span class="n-b">Cut in the middle: the difference survives</span>
</p>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.