Toast — arrive and expire
Variant: Arrive and expire
The baseline lifecycle of the most ephemeral surface in an interface: 259ms of rise on the way in, 180ms of fall on the way out, and between them a 2px rail draining linearly across 3.6 seconds — linear because a timeout is a clock and a clock does not ease. The rail starts on the frame the toast lands, since a lifetime should not be spent arriving. The asymmetry carries the etiquette: the entrance is a bid for attention and gets the deliberate curve, the exit is an admission that the moment has passed and nobody should be made to watch it. Reach for it wherever a confirmation matters for three seconds and not four.
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>Toast — arrive and expire</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 — 4.8s: 259ms in, 3.6s of visible lifetime, 180ms out. */
--cycle: 4.8s;
--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);
}
.frame {
position: relative;
width: clamp(230px, 56vw, 320px);
height: min(64vh, 72vw, 210px);
border-radius: calc(12px * var(--round));
background: var(--paper);
border: 1px solid color-mix(in srgb, var(--slate) 10%, transparent);
overflow: hidden;
}
.page {
position: absolute;
inset: 0;
padding: 16px;
display: grid;
gap: 10px;
align-content: start;
}
.bar {
height: 10px;
border-radius: 5px;
background: var(--oat);
}
.page .head {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.page .dot {
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--oat);
flex: none;
}
.slot {
position: absolute;
left: 0;
right: 0;
bottom: 12px;
display: grid;
justify-items: center;
}
/* 16px of rise and 259ms in, 10px of fall and 180ms out. The exit is
leaving the way it came, faster — nobody is waiting for a toast to
finish going. */
.toast {
position: relative;
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px 11px;
border-radius: calc(9px * var(--round));
background: var(--paper);
border: 1px solid color-mix(in srgb, var(--slate) 12%, transparent);
box-shadow: 0 6px 18px color-mix(in srgb, var(--slate) 12%, transparent);
overflow: hidden;
opacity: 0;
transform: translateY(16px);
animation: toast var(--t) linear infinite;
}
.toast .tick {
width: 15px;
height: 15px;
flex: none;
color: var(--clay);
}
.toast .tick svg {
width: 100%;
height: 100%;
display: block;
}
.toast .label {
font-size: 11.5px;
font-weight: 500;
letter-spacing: -0.005em;
white-space: nowrap;
}
/* The lifetime made visible. It starts draining on the frame the toast
lands — legibility is when the clock starts — and it drains linearly,
because a timeout is a clock and a clock does not ease. */
.rail {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 2px;
background: var(--clay);
transform-origin: left center;
animation: rail var(--t) linear infinite;
}
@keyframes toast {
0%,
5% {
opacity: 0;
transform: translateY(16px);
animation-timing-function: var(--ease-out);
}
10.4%,
85% {
opacity: 1;
transform: translateY(0);
animation-timing-function: var(--ease-out);
}
88.75%,
100% {
opacity: 0;
transform: translateY(10px);
}
}
@keyframes rail {
0%,
10.4% {
transform: scaleX(1);
animation-timing-function: linear;
}
85%,
100% {
transform: scaleX(0);
}
}
@media (prefers-reduced-motion: reduce) {
/* The travel goes; the toast crossfades in place. The rail keeps
draining — it is the subject, and it is a clock rather than a
flourish. */
.toast {
transform: translateY(0);
animation-name: toast-rm;
}
.toast,
.rail {
animation-duration: calc(var(--t) * 1.6);
}
@keyframes toast-rm {
0%,
5% {
opacity: 0;
animation-timing-function: ease;
}
10.4%,
85% {
opacity: 1;
animation-timing-function: ease;
}
88.75%,
100% {
opacity: 0;
}
}
}
</style>
</head>
<body>
<div
class="frame"
role="img"
aria-label="A toast notification rising over a page, its lifetime bar draining, then slipping away"
>
<div class="page">
<div class="head">
<span class="dot"></span>
<span class="bar" style="width: 42%"></span>
</div>
<span class="bar" style="width: 88%"></span>
<span class="bar" style="width: 74%"></span>
<span class="bar" style="width: 81%"></span>
</div>
<div class="slot">
<div class="toast">
<span class="tick">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="2" />
<path
d="m8.4 12.2 2.5 2.5 4.7-5"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</span>
<span class="label">Draft saved</span>
<span class="rail"></span>
</div>
</div>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.