Latch — over-centre
Variant: Over-centre
The light-switch mechanism, and the one gesture where the hand should be outrun. A lever pushed twice. The first push stops at −7°, short of centre, and when the finger lifts the lever falls back on an ease-in. Near the crest the spring has almost no leverage and it gains leverage on the way down, so the lever is still speeding up when it hits the stop and gives 1.2° of recoil, not a settle. The second push follows the hand's curve exactly as far as 0°, then the spring takes over: 28° in 150ms. That curve starts at the hand's speed, so the handover has no hitch, and finishes at about twenty times that speed, so it seats with a knock. The finger drifts on 6° and is left behind. The ball below is the same angle drawn as energy, a double well with the hand doing the uphill work, and the word ON changes on the frame the lever seats, not when it crosses centre. Reach for it for any bistable control you want to feel committed: toggles, mode switches, a drawer that should not stop halfway.
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>Latch — over-centre</title>
<style>
/* Two registered angles: where the lever is (--_a) and where the hand
is (--_h). They share keyframes while the finger is on the lever,
so they are identical until the frame the mechanism takes over. The
ball below reads the same --_a, so the lever and its energy can
never disagree. */
@property --_a {
syntax: '<number>';
inherits: true;
initial-value: -28;
}
@property --_h {
syntax: '<number>';
inherits: true;
initial-value: -28;
}
: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) 52%, transparent);
--_faint: color-mix(in srgb, var(--slate) 22%, transparent);
--_stem: color-mix(in srgb, var(--slate) 78%, transparent);
/* Clock — 6.4s: a push that stops short, a push that crosses, a reset. */
--cycle: 6.4s;
--t: calc(var(--cycle) / var(--speed));
}
* {
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);
}
.rig {
display: grid;
gap: clamp(8px, 3vh, 14px);
justify-items: center;
animation:
lever var(--t) infinite,
hand var(--t) infinite,
rig-cycle var(--t) linear infinite;
}
.cap,
.foot {
font-size: 11px;
letter-spacing: 0.04em;
color: var(--_muted);
}
.foot {
display: grid;
justify-items: center;
}
.foot span {
grid-area: 1 / 1;
opacity: 0;
white-space: nowrap;
}
.foot .short {
animation: foot-short var(--t) linear infinite;
}
.foot .past {
animation: foot-past var(--t) linear infinite;
}
.switch {
display: flex;
align-items: flex-end;
gap: 10px;
}
.lab {
font-size: 12px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
padding-bottom: 1px;
}
.lab.off {
animation: lab-off var(--t) infinite;
}
.lab.on {
color: var(--_faint);
animation: lab-on var(--t) infinite;
}
.body {
position: relative;
width: 96px;
height: 64px;
}
/* Both arms pivot on the same point; the lever and the hand are two
rotations about one axis, which is what a toggle actually is. */
.arm {
position: absolute;
left: 48px;
top: 52px;
width: 0;
height: 0;
}
.arm.lever {
transform: rotate(calc(var(--_a) * 1deg));
}
.arm.hand {
transform: rotate(calc(var(--_h) * 1deg));
}
.stem {
position: absolute;
left: -4px;
top: -44px;
width: 8px;
height: 44px;
border-radius: 4px;
background: var(--_stem);
}
.knob {
position: absolute;
left: -8px;
top: -52px;
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--paper);
border: 1.5px solid var(--oat);
box-shadow: 0 1px 3px color-mix(in srgb, var(--slate) 18%, transparent);
}
/* The fingertip sits on the knob's off side, so it can push the lever
toward on and can never pull it back. */
.tip {
position: absolute;
left: -28px;
top: -54px;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--clay-d);
opacity: 0;
transform: scale(0.6);
animation: grip var(--t) infinite;
}
.housing {
position: absolute;
left: 16px;
top: 48px;
width: 64px;
height: 16px;
border-radius: calc(5px * var(--round));
background: var(--oat);
}
.housing::after {
content: '';
position: absolute;
left: 31.25px;
top: 3px;
width: 1.5px;
height: 4px;
background: var(--_muted);
}
.well {
position: relative;
width: 200px;
height: 60px;
}
.well svg {
display: block;
overflow: visible;
}
.curve {
fill: none;
stroke: var(--oat);
stroke-width: 2;
stroke-linejoin: round;
}
.centre {
stroke: var(--_faint);
stroke-width: 1;
stroke-dasharray: 2 3;
}
/* The ball is the lever's angle drawn as energy: x is the angle, y is
the same sin² double well the curve is plotted from. Uphill is the
hand's work; downhill is the spring's. */
.ball {
position: absolute;
left: 0;
top: 0;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--clay-d);
transform: translate(
calc((100 + var(--_a) * 66 / 28) * 1px - 5px),
calc(
(14 + 36 * sin(calc(var(--_a) * 3.2143deg)) * sin(calc(var(--_a) * 3.2143deg))) * 1px -
10px
)
);
}
/* The lever. Push one is the hand's curve to -7°, short of centre:
released, it falls back on an ease-in, because the restoring force
is weakest near the crest and grows on the way down, so it is still
accelerating when it reaches the stop — 1.2° of recoil, not a
settle. Push two shares the hand's curve exactly until 0°, then
leaves it: 28° in 150ms on a curve whose opening slope is matched
to the hand's velocity at the crest, so the takeover has no hitch,
and whose end is twenty times the hand's speed, so the seat is a knock. */
@keyframes lever {
0%,
6.875% {
--_a: -28;
animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}
19.375%,
22.5% {
--_a: -7;
animation-timing-function: cubic-bezier(0.55, 0, 0.9, 0.6);
}
25.78% {
--_a: -28;
animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1);
}
26.41% {
--_a: -26.8;
animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}
27.19%,
48.44% {
--_a: -28;
animation-timing-function: cubic-bezier(0.45, 0, 0.6, 0.8);
}
56.25% {
--_a: 0;
animation-timing-function: cubic-bezier(0.4, 0.06, 0.85, 0.55);
}
58.59% {
--_a: 28;
animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1);
}
59.22% {
--_a: 26.8;
animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}
60%,
100% {
--_a: 28;
}
}
/* The hand carries on past the crest on its own momentum — 6° more,
decelerating — so the lever visibly outruns the finger that sent it. */
@keyframes hand {
0%,
6.875% {
--_h: -28;
animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}
19.375%,
30% {
--_h: -7;
}
30.01%,
48.44% {
--_h: -28;
animation-timing-function: cubic-bezier(0.45, 0, 0.6, 0.8);
}
56.25% {
--_h: 0;
animation-timing-function: cubic-bezier(0.3, 0.28, 0.4, 1);
}
59.375%,
100% {
--_h: 6;
}
}
@keyframes grip {
0%,
3.75% {
opacity: 0;
transform: scale(0.6);
animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
}
6.875%,
22.5% {
opacity: 0.4;
transform: scale(1);
animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
}
24.84%,
45.31% {
opacity: 0;
transform: scale(0.6);
animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
}
48.44%,
61.72% {
opacity: 0.4;
transform: scale(1);
animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
}
64.06%,
100% {
opacity: 0;
transform: scale(0.6);
}
}
/* The state word changes on the frame the lever seats, not when the
hand crosses centre: between those frames it is neither. */
@keyframes lab-off {
0%,
58.5% {
color: var(--slate);
}
58.59%,
100% {
color: var(--_faint);
}
}
@keyframes lab-on {
0%,
58.5% {
color: var(--_faint);
}
58.59%,
100% {
color: var(--clay-d);
}
}
@keyframes foot-short {
0%,
26.56% {
opacity: 0;
}
28.91%,
45.31% {
opacity: 1;
}
47.66%,
100% {
opacity: 0;
}
}
@keyframes foot-past {
0%,
60.16% {
opacity: 0;
}
62.5%,
100% {
opacity: 1;
}
}
@keyframes rig-cycle {
0% {
opacity: 0;
}
2.5%,
92.19% {
opacity: 1;
}
95.31%,
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
/* The throw goes; the outcome stays. The lever is parked on, the
ball sits in the right-hand well, and the line says why. */
.rig,
.tip,
.lab.off,
.lab.on,
.foot .short,
.foot .past {
animation: none;
}
.rig {
--_a: 28;
--_h: 28;
}
.lab.off {
color: var(--_faint);
}
.lab.on {
color: var(--clay-d);
}
.foot .past {
opacity: 1;
}
}
</style>
</head>
<body>
<div
class="rig"
role="img"
aria-label="A toggle lever pushed twice. Released short of centre it falls back to off; pushed just past centre it snaps the rest of the way to on by itself, ahead of the finger. A double-well energy curve below shows the lever's state as a ball."
>
<p class="cap">latch · over-centre</p>
<div class="switch">
<span class="lab off">off</span>
<div class="body">
<div class="arm lever"><i class="stem"></i><i class="knob"></i></div>
<div class="arm hand"><i class="tip"></i></div>
<i class="housing"></i>
</div>
<span class="lab on">on</span>
</div>
<div class="well">
<svg viewBox="0 0 200 60" width="200" height="60" aria-hidden="true">
<line class="centre" x1="100" y1="4" x2="100" y2="58" />
<path
class="curve"
d="M29,10 L29,50 L34,50 L38.7,49.5 L43.4,48.2 L48.1,46.1 L52.9,43.2 L57.6,39.8 L62.3,36 L67,32 L71.7,28 L76.4,24.2 L81.1,20.8 L85.9,17.9 L90.6,15.8 L95.3,14.5 L100,14 L104.7,14.5 L109.4,15.8 L114.1,17.9 L118.9,20.8 L123.6,24.2 L128.3,28 L133,32 L137.7,36 L142.4,39.8 L147.1,43.2 L151.9,46.1 L156.6,48.2 L161.3,49.5 L166,50 L171,50 L171,10"
/>
</svg>
<i class="ball"></i>
</div>
<p class="foot">
<span class="short">let go short of centre — it falls back</span>
<span class="past">pushed past centre — it finishes the throw</span>
</p>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.