Hover — fill from the edge you crossed
Variant: Edge-aware fill
A two-by-two grid where each tile fills from the edge the pointer came through and empties toward the edge it left by, so moving from one tile into its neighbour reads as a single colour travelling with the hand instead of one light going off and another going on. The wipe is a clip-path inset, which composites without touching layout; working out the edge in production is four lines — compare the entry point to the tile’s centre against its two diagonals. Entering takes 192ms and leaving 144ms, both ease-out: the hand is already in the next tile, and the old one should clear out of its way a beat faster than the new one arrives. Across the gap between tiles the exit and the entry run in the same direction and overlap by a few frames, which is what makes the handoff look continuous. Team, bottom left, is never touched and never lights — the proof that only what the pointer is over answers it. Reach for it on dense navigational grids, dashboards of cards and pricing tables, where a plain fade-in hover makes a fast sweep across the grid flash like a keyboard.
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>Hover — fill from the edge you crossed</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, so 1% is 48ms. Fills enter over 4% (192ms) and leave
over 3% (144ms). Crossings: into A at 9%, A→B at 26.7/27.3%, B→D at
45.4/46.2%, out of D at 63%. */
--cycle: 4.8s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
/* The hand: a sine, so every crossing above sits where it was solved. */
--_hand: cubic-bezier(0.45, 0, 0.55, 1);
--_fill: color-mix(in srgb, var(--clay) 18%, var(--paper));
--_muted: color-mix(in srgb, var(--slate) 54%, transparent);
}
* {
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);
}
.stage {
position: relative;
width: 236px;
height: 180px;
}
.grid {
position: absolute;
left: 12px;
top: 12px;
display: grid;
grid-template-columns: 100px 100px;
grid-auto-rows: 68px;
gap: 12px;
}
.tile {
position: relative;
overflow: hidden;
display: grid;
align-content: end;
gap: 2px;
padding: 10px 12px;
background: var(--paper);
border: 1px solid var(--oat);
border-radius: calc(10px * var(--round));
}
.tile b,
.tile small {
position: relative;
}
.tile b {
font-size: 13px;
font-weight: 600;
letter-spacing: -0.01em;
}
.tile small {
font-size: 11px;
color: var(--_muted);
}
.fill {
position: absolute;
inset: 0;
background: var(--_fill);
clip-path: inset(0 100% 0 0);
animation: var(--t) var(--ease-out) infinite;
}
.a .fill {
animation-name: fill-a;
}
.b .fill {
animation-name: fill-b;
}
.d .fill {
clip-path: inset(0 0 100% 0);
animation-name: fill-d;
}
.c .fill {
animation: none;
}
/* A: in from the left, out to the right — the pointer kept going east,
so the colour does too. Leaving is a quarter faster than arriving:
the hand is already somewhere else and the old tile should get out of
the way of the new one. */
@keyframes fill-a {
0%,
9% {
clip-path: inset(0 100% 0 0);
}
13%,
26.7% {
clip-path: inset(0 0 0 0);
}
29.7%,
100% {
clip-path: inset(0 0 0 100%);
}
}
/* B: in from the left, out through the floor. Across the gap the exit
of one tile and the entry of the next run in the same direction, so
the two wipes read as one colour travelling with the hand. */
@keyframes fill-b {
0%,
27.3% {
clip-path: inset(0 100% 0 0);
}
31.3%,
45.4% {
clip-path: inset(0 0 0 0);
}
48.4%,
100% {
clip-path: inset(100% 0 0 0);
}
}
@keyframes fill-d {
0%,
46.2% {
clip-path: inset(0 0 100% 0);
}
50.2%,
63% {
clip-path: inset(0 0 0 0);
}
66%,
100% {
clip-path: inset(100% 0 0 0);
}
}
.ghost {
position: absolute;
left: 0;
top: 0;
width: 14px;
height: 18px;
opacity: 0;
transform: translate(-20px, 20px);
animation:
travel var(--t) var(--_hand) infinite,
presence var(--t) var(--ease-out) infinite;
}
.arrow {
display: block;
width: 100%;
height: 100%;
fill: var(--slate);
stroke: var(--ivory);
stroke-width: 1.4;
stroke-linejoin: round;
}
/* Every horizontal leg is placed so the boundary it crosses sits at its
spatial midpoint, which on a symmetric curve is also its temporal
midpoint. The pointer rides the top of the tiles so it never parks on a label. */
@keyframes travel {
0%,
4% {
transform: translate(-20px, 20px);
}
14%,
22% {
transform: translate(44px, 20px);
}
32%,
40% {
transform: translate(192px, 20px);
}
50%,
58% {
transform: translate(178px, 126px);
}
68%,
74% {
transform: translate(178px, 194px);
}
75%,
100% {
transform: translate(-20px, 20px);
}
}
@keyframes presence {
0% {
opacity: 0;
}
4%,
70% {
opacity: 1;
}
74%,
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
/* No wipes and no travelling pointer — direction is the one thing this
state cannot carry. The tiles still light and dim in the same order
on the same beats, as plain fades, half again as slowly. */
.ghost {
display: none;
}
.fill {
clip-path: none;
opacity: 0;
animation-duration: calc(var(--t) * 1.5);
}
.d .fill {
clip-path: none;
}
.a .fill {
animation-name: soft-a;
}
.b .fill {
animation-name: soft-b;
}
.d .fill {
animation-name: soft-d;
}
@keyframes soft-a {
0%,
9% {
opacity: 0;
}
13%,
26.7% {
opacity: 1;
}
29.7%,
100% {
opacity: 0;
}
}
@keyframes soft-b {
0%,
27.3% {
opacity: 0;
}
31.3%,
45.4% {
opacity: 1;
}
48.4%,
100% {
opacity: 0;
}
}
@keyframes soft-d {
0%,
46.2% {
opacity: 0;
}
50.2%,
63% {
opacity: 1;
}
66%,
100% {
opacity: 0;
}
}
}
</style>
</head>
<body>
<div
class="stage"
role="img"
aria-label="A pointer crosses a two-by-two grid of tiles; each tile it enters fills with colour from the edge the pointer came through and empties toward the edge it leaves by, so the colour appears to travel with the hand from tile to tile"
>
<div class="grid">
<div class="tile a">
<span class="fill"></span><b>Docs</b><small>12 pages</small>
</div>
<div class="tile b">
<span class="fill"></span><b>Billing</b><small>Pro plan</small>
</div>
<div class="tile c">
<span class="fill"></span><b>Team</b><small>4 seats</small>
</div>
<div class="tile d">
<span class="fill"></span><b>Logs</b><small>Live</small>
</div>
</div>
<span class="ghost">
<svg class="arrow" viewBox="0 0 14 18">
<path d="M1 1 L1 14.8 L4.5 11.6 L6.7 16.6 L9.3 15.4 L7.1 10.5 L11.8 10.3 Z" />
</svg>
</span>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.