Pane — collapse to rail
Variant: Collapse to rail
A sidebar folding to an icon rail and back, and the lesson is the order. Collapsing, the labels fade in 104ms before the edge moves, then the edge travels for 286ms; expanding, the edge opens for 312ms first and the labels return only once it has stopped, staggered 31ms down the list. Anything that exists only in the wide state leaves first and arrives last — otherwise a label is sliced letter by letter by a clip edge crossing it. The gained room obeys the same rule mirrored: the page is sized for the rail and overhangs while the sidebar is wide, and its timestamp column fades in only after the edge lands. The icons never move, which is what lets the rail read as the same sidebar rather than a different component. Use it for any navigation that trades its labels for room.
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>Pane — collapse to rail</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)
);
/* Clock — 5.2s, so 1% is 52ms. Collapse: labels out in 104ms, then
the edge travels for 286ms. Expand: the edge travels for 312ms, then
the labels return. */
--cycle: 5.2s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
--ease-accent: cubic-bezier(0.32, 0.72, 0, 1);
/* The rail is the icon column and nothing else: 6px gutter, 28px cell,
6px gutter. Everything the collapse moves is measured against it. */
--_rail: 40px;
--_side: 44cqw;
--_shift: calc(var(--_rail) - var(--_side));
}
* {
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);
}
.frame {
position: relative;
width: clamp(250px, 64vw, 380px);
height: clamp(160px, 58vh, 220px);
container-type: size;
border-radius: calc(12px * var(--round));
background: var(--paper);
border: 1px solid color-mix(in srgb, var(--slate) 10%, transparent);
overflow: hidden;
}
/* The sidebar never changes width — it is clipped. The clip edge and the
main pane's shift are one movement on one curve, so the divider is
never ahead of or behind the edge it belongs to. */
.side {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: var(--_side);
padding: 8px 6px;
display: flex;
flex-direction: column;
gap: 4px;
background: color-mix(in srgb, var(--oat) 28%, var(--paper));
clip-path: inset(0 0 0 0);
animation: side-clip var(--t) infinite;
}
.item {
position: relative;
display: flex;
align-items: center;
gap: 8px;
height: 26px;
font-size: 12px;
letter-spacing: -0.005em;
white-space: nowrap;
}
/* Icons sit in a fixed 28px cell at the left, the one thing both states
share, so they never move. That stillness is what lets the eye accept
the rail as the same sidebar rather than a different component. */
.icon {
position: relative;
z-index: 1;
width: 28px;
height: 26px;
flex: none;
display: grid;
place-items: center;
color: color-mix(in srgb, var(--slate) 58%, transparent);
}
.icon svg {
width: 14px;
height: 14px;
display: block;
}
.label {
position: relative;
z-index: 1;
color: color-mix(in srgb, var(--slate) 78%, transparent);
animation: label var(--t) infinite;
}
.item:nth-child(2) .label {
animation-name: label-2;
}
.item:nth-child(3) .label {
animation-name: label-3;
}
.item.on .icon,
.item.on .label {
color: var(--clay-d);
}
/* The selection pill has its own clip so it can end as a rounded square
around the icon. Under the sidebar's clip alone it would be guillotined
flat on its right side at the rail edge. */
.hl {
position: absolute;
inset: 0;
border-radius: calc(6px * var(--round));
background: color-mix(in srgb, var(--clay) 13%, transparent);
clip-path: inset(0 0 0 0 round calc(6px * var(--round)));
animation: hl-clip var(--t) infinite;
}
.toggle {
margin-top: auto;
width: 28px;
height: 26px;
display: grid;
place-items: center;
position: relative;
color: color-mix(in srgb, var(--slate) 50%, transparent);
}
.toggle svg {
width: 14px;
height: 14px;
display: block;
animation: chevron var(--t) infinite;
}
.tap {
position: absolute;
left: 50%;
top: 50%;
width: 26px;
height: 26px;
margin: -13px 0 0 -13px;
border-radius: 50%;
background: color-mix(in srgb, var(--slate) 12%, transparent);
opacity: 0;
animation: tap var(--t) infinite;
}
/* The main pane is sized for the collapsed state and overhangs the
frame while the sidebar is wide, so the collapse genuinely gains
room: the timestamp column parked past the edge is what fills it. */
.main {
position: absolute;
top: 0;
bottom: 0;
left: var(--_side);
width: calc(100cqw - var(--_rail));
padding: 12px 14px;
display: flex;
flex-direction: column;
gap: 9px;
border-left: 1px solid color-mix(in srgb, var(--slate) 9%, transparent);
animation: main-shift var(--t) infinite;
}
.title {
font-size: 12.5px;
font-weight: 600;
letter-spacing: -0.01em;
margin-bottom: 2px;
}
.row {
display: flex;
align-items: center;
gap: 8px;
height: 14px;
}
.dot {
width: 6px;
height: 6px;
flex: none;
border-radius: 50%;
background: color-mix(in srgb, var(--slate) 20%, transparent);
}
.row.new .dot {
background: var(--clay);
}
.bar {
display: block;
height: 7px;
border-radius: 3.5px;
background: color-mix(in srgb, var(--slate) 12%, transparent);
}
.time {
margin-left: auto;
font-size: 11px;
font-variant-numeric: tabular-nums;
color: color-mix(in srgb, var(--slate) 48%, transparent);
opacity: 0;
animation: meta var(--t) infinite;
}
/* The room's new content obeys the same rule as the labels, mirrored:
it arrives only once the edge has landed and leaves before the edge
starts back, so nothing is ever read through a moving boundary. */
@keyframes meta {
0%,
18.5% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
22%,
55% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
57%,
100% {
opacity: 0;
}
}
/* Anything that exists only in the wide state leaves first and arrives
last. A label still visible when the edge starts moving gets sliced
letter by letter as the clip crosses it; a label that fades in while
the edge is still opening is read through a moving window. */
@keyframes label {
0%,
11% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
13%,
63% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
67%,
100% {
opacity: 1;
}
}
/* Return is staggered 31ms per row, top down, so the list re-reads in
the order it is read. Departure is not: leaving is housekeeping. */
@keyframes label-2 {
0%,
11% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
13%,
63.6% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
67.6%,
100% {
opacity: 1;
}
}
@keyframes label-3 {
0%,
11% {
opacity: 1;
animation-timing-function: var(--ease-out);
}
13%,
64.2% {
opacity: 0;
animation-timing-function: var(--ease-out);
}
68.2%,
100% {
opacity: 1;
}
}
@keyframes side-clip {
0%,
13% {
clip-path: inset(0 0 0 0);
animation-timing-function: var(--ease-accent);
}
18.5%,
57% {
clip-path: inset(0 calc(100% - var(--_rail)) 0 0);
animation-timing-function: var(--ease-accent);
}
63%,
100% {
clip-path: inset(0 0 0 0);
}
}
@keyframes hl-clip {
0%,
13% {
clip-path: inset(0 0 0 0 round calc(6px * var(--round)));
animation-timing-function: var(--ease-accent);
}
18.5%,
57% {
clip-path: inset(0 calc(100% - 28px) 0 0 round calc(6px * var(--round)));
animation-timing-function: var(--ease-accent);
}
63%,
100% {
clip-path: inset(0 0 0 0 round calc(6px * var(--round)));
}
}
@keyframes main-shift {
0%,
13% {
transform: translateX(0);
animation-timing-function: var(--ease-accent);
}
18.5%,
57% {
transform: translateX(var(--_shift));
animation-timing-function: var(--ease-accent);
}
63%,
100% {
transform: translateX(0);
}
}
/* The chevron is under the finger, so it answers on the press frame —
a beat before the labels go and two before the edge moves. */
@keyframes chevron {
0%,
10.5% {
transform: rotate(0deg);
animation-timing-function: var(--ease-accent);
}
15%,
55.5% {
transform: rotate(180deg);
animation-timing-function: var(--ease-accent);
}
60%,
100% {
transform: rotate(0deg);
}
}
@keyframes tap {
0%,
7% {
opacity: 0;
transform: scale(1.3);
animation-timing-function: var(--ease-out);
}
10%,
11% {
opacity: 1;
transform: scale(1);
animation-timing-function: var(--ease-out);
}
15%,
52% {
opacity: 0;
transform: scale(1.3);
animation-timing-function: var(--ease-out);
}
55%,
56% {
opacity: 1;
transform: scale(1);
animation-timing-function: var(--ease-out);
}
60%,
100% {
opacity: 0;
transform: scale(1.3);
}
}
@media (prefers-reduced-motion: reduce) {
/* The geometry still changes — the rail is a different layout, not a
decoration — but on one frame, as an app with no animation would.
The labels keep their fade and their order, which is the part that
carries the meaning: they go before the edge and come back after. */
.side {
animation-name: side-clip-step;
}
.hl {
animation-name: hl-clip-step;
}
.main {
animation-name: main-shift-step;
}
.toggle svg {
animation-name: chevron-step;
}
.tap {
transform: none;
animation-name: tap-still;
}
.side,
.hl,
.main,
.toggle svg,
.tap,
.label,
.time {
animation-duration: calc(var(--t) * 1.5);
}
@keyframes side-clip-step {
0%,
15% {
clip-path: inset(0 0 0 0);
animation-timing-function: steps(1, end);
}
15.1%,
60% {
clip-path: inset(0 calc(100% - var(--_rail)) 0 0);
animation-timing-function: steps(1, end);
}
60.1%,
100% {
clip-path: inset(0 0 0 0);
}
}
@keyframes hl-clip-step {
0%,
15% {
clip-path: inset(0 0 0 0 round calc(6px * var(--round)));
animation-timing-function: steps(1, end);
}
15.1%,
60% {
clip-path: inset(0 calc(100% - 28px) 0 0 round calc(6px * var(--round)));
animation-timing-function: steps(1, end);
}
60.1%,
100% {
clip-path: inset(0 0 0 0 round calc(6px * var(--round)));
}
}
@keyframes main-shift-step {
0%,
15% {
transform: translateX(0);
animation-timing-function: steps(1, end);
}
15.1%,
60% {
transform: translateX(var(--_shift));
animation-timing-function: steps(1, end);
}
60.1%,
100% {
transform: translateX(0);
}
}
@keyframes chevron-step {
0%,
11% {
transform: rotate(0deg);
animation-timing-function: steps(1, end);
}
11.1%,
56% {
transform: rotate(180deg);
animation-timing-function: steps(1, end);
}
56.1%,
100% {
transform: rotate(0deg);
}
}
@keyframes tap-still {
0%,
7% {
opacity: 0;
animation-timing-function: ease;
}
10%,
11% {
opacity: 1;
animation-timing-function: ease;
}
15%,
52% {
opacity: 0;
animation-timing-function: ease;
}
55%,
56% {
opacity: 1;
animation-timing-function: ease;
}
60%,
100% {
opacity: 0;
}
}
}
</style>
</head>
<body>
<div
class="frame"
role="img"
aria-label="A sidebar collapsing to an icon rail: the labels fade first, then the edge slides in, the page follows and a timestamp column fills the gained room; on expand the timestamps leave, the edge opens first and the labels return after it"
>
<nav class="side">
<div class="item on">
<span class="hl"></span>
<span class="icon">
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M2 9.5h3.2l1 1.8h3.6l1-1.8H14M2 9.5 3.6 3.5h8.8L14 9.5V13H2z"
stroke="currentColor"
stroke-width="1.5"
stroke-linejoin="round"
/>
</svg>
</span>
<span class="label">Inbox</span>
</div>
<div class="item">
<span class="icon">
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M2 4.2h4.4l1.4 1.6H14V13H2z"
stroke="currentColor"
stroke-width="1.5"
stroke-linejoin="round"
/>
</svg>
</span>
<span class="label">Projects</span>
</div>
<div class="item">
<span class="icon">
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="M3 13V8.5M8 13V3.5M13 13V6.5"
stroke="currentColor"
stroke-width="1.6"
stroke-linecap="round"
/>
</svg>
</span>
<span class="label">Reports</span>
</div>
<span class="toggle">
<span class="tap"></span>
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
<path
d="m9.5 4-4 4 4 4"
stroke="currentColor"
stroke-width="1.6"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</span>
</nav>
<section class="main">
<span class="title">Inbox</span>
<div class="row new">
<span class="dot"></span><span class="bar" style="width: 34%"></span
><span class="time">9:41</span>
</div>
<div class="row new">
<span class="dot"></span><span class="bar" style="width: 44%"></span
><span class="time">9:12</span>
</div>
<div class="row">
<span class="dot"></span><span class="bar" style="width: 28%"></span
><span class="time">Tue</span>
</div>
<div class="row">
<span class="dot"></span><span class="bar" style="width: 40%"></span
><span class="time">Mon</span>
</div>
<div class="row">
<span class="dot"></span><span class="bar" style="width: 31%"></span
><span class="time">Sep 30</span>
</div>
</section>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.