Hover — highlight glides inside, fades at the edge
Variant: Glide highlight
One highlight for a whole menu, and the rule that decides whether it moves: inside the list it glides, across the list’s edge it never does. Row to row is 160ms of ease-out, trailing the pointer by the length of a glance; on a two-row run it is retargeted on each row’s enter, as a real one is, carrying its speed through the middle row rather than stopping there and never heading for the last row before the pointer has reached it. When the pointer leaves out of the side, the highlight fades where it is in 120ms with no scale — exits are quieter than entrances — and when the pointer comes back in on the top row, the highlight appears there, 150ms from 97% scale, having been repositioned while invisible. A pill that slid up from the bottom row it was last seen on would be describing a path the hand never took, which is the commonest bug in every shared-highlight implementation. Delete stays rust whether or not it is highlighted; the highlight says where you are, never what the row does. Reach for it on menus, command palettes, tab bars and sidebars, anywhere rows sit close enough that a hover can travel between them.
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 — highlight glides inside, fades at the edge</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 — 6s, so 1% is 60ms. In on Rename at 9%, glide to Duplicate
at 22.5%, a run to Delete from 34.3%, out of the side at 53.7%, back
in on Open at 74.6%, out of the top at 88.5%. */
--cycle: 6s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
--_hand: cubic-bezier(0.45, 0, 0.55, 1);
--_muted: color-mix(in srgb, var(--slate) 46%, transparent);
--_pill: color-mix(in srgb, var(--oat) 70%, var(--paper));
}
* {
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: 200px;
height: 174px;
}
.menu {
position: absolute;
inset: 0;
padding: 6px 0;
background: var(--paper);
border: 1px solid var(--oat);
border-radius: calc(12px * var(--round));
box-shadow: 0 8px 24px color-mix(in srgb, var(--slate) 8%, transparent);
}
.slot {
position: absolute;
left: 6px;
right: 6px;
top: 6px;
height: 32px;
transform: translateY(32px);
animation: slot var(--t) infinite;
}
.pill {
width: 100%;
height: 100%;
border-radius: calc(7px * var(--round));
background: var(--_pill);
opacity: 0;
transform: scale(0.97);
animation: pill var(--t) var(--ease-out) infinite;
}
.item {
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
height: 32px;
padding: 0 16px;
font-size: 13px;
}
.item kbd {
font: inherit;
font-size: 11px;
color: var(--_muted);
font-variant-numeric: tabular-nums;
}
.item.danger {
color: var(--rust);
}
/* Inside the list the highlight is one object that moves: 160ms of
ease-out per row, trailing the hand by the length of a glance. On a
two-row run it is retargeted on each row's enter, as a real one is —
it carries its speed through Move to… instead of stopping there, and
never heads for Delete before the pointer has reached it. Curves are
literal: var() in a keyframe is ignored. */
@keyframes slot {
0%,
22.5% {
transform: translateY(32px);
animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
}
25.2%,
34.3% {
transform: translateY(64px);
animation-timing-function: cubic-bezier(0.2, 0.7, 0.6, 0.9);
}
37% {
transform: translateY(98px);
animation-timing-function: cubic-bezier(0.3, 0.4, 0.3, 1);
}
39.7%,
74.5% {
transform: translateY(128px);
}
74.6%,
100% {
transform: translateY(0);
}
}
/* Across the list's edge it is never moved. It appears where the hand
came in — 150ms, from 97% scale, never from nothing — and leaves where
the hand went out in 120ms with no scale at all, because exits should
be quieter than entrances. Coming back in on a different row repositions
it while it is invisible: a pill that slid from the last row it was on
would be describing a path the pointer never took. */
@keyframes pill {
0%,
9% {
opacity: 0;
transform: scale(0.97);
}
11.5%,
53.7% {
opacity: 1;
transform: scale(1);
}
55.7% {
opacity: 0;
transform: scale(1);
}
74.6% {
opacity: 0;
transform: scale(0.97);
}
77.1%,
88.5% {
opacity: 1;
transform: scale(1);
}
90.5% {
opacity: 0;
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(0.97);
}
}
.ghost {
position: absolute;
left: 0;
top: 0;
width: 14px;
height: 18px;
opacity: 0;
transform: translate(-40px, 58px);
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;
}
@keyframes travel {
0%,
5% {
transform: translate(-40px, 58px);
}
13%,
20% {
transform: translate(40px, 58px);
}
26%,
32% {
transform: translate(70px, 90px);
}
40%,
48% {
transform: translate(66px, 154px);
}
56%,
64% {
transform: translate(232px, 140px);
}
72% {
transform: translate(232px, 26px);
}
78%,
86% {
transform: translate(150px, 22px);
}
92%,
96% {
transform: translate(150px, -20px);
}
97%,
100% {
transform: translate(-40px, 58px);
}
}
@keyframes presence {
0% {
opacity: 0;
}
4%,
92% {
opacity: 1;
}
96%,
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
/* The highlight hops between rows instead of gliding, and the pointer
is hidden. The rule the piece exists for survives intact: it still
fades in on the row where the pointer would enter and out on the row
it would leave, on the same beats, half again as slowly. */
.ghost {
display: none;
}
.slot {
animation: slot-hop calc(var(--t) * 1.5) infinite;
}
.pill {
animation-duration: calc(var(--t) * 1.5);
}
@keyframes slot-hop {
0%,
22.4% {
transform: translateY(32px);
}
22.5%,
34.3% {
transform: translateY(64px);
}
34.4%,
36.9% {
transform: translateY(96px);
}
37%,
74.5% {
transform: translateY(128px);
}
74.6%,
100% {
transform: translateY(0);
}
}
}
</style>
</head>
<body>
<div
class="stage"
role="img"
aria-label="A pointer moves down a menu; one highlight glides from row to row under it, then fades out in place when the pointer leaves the side of the menu; when the pointer re-enters on the top row the highlight fades in there rather than sliding up from where it last was"
>
<div class="menu">
<div class="slot"><div class="pill"></div></div>
<div class="item"><span>Open</span><kbd>⌘O</kbd></div>
<div class="item"><span>Rename</span><kbd>F2</kbd></div>
<div class="item"><span>Duplicate</span><kbd>⌘D</kbd></div>
<div class="item"><span>Move to…</span><kbd>⌘M</kbd></div>
<div class="item danger"><span>Delete</span><kbd>⌫</kbd></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.