Wire — drag to connect
Variant: Connect
Making an edge by hand in a node editor, and the three moments a good one keeps apart: aiming, catching and committing. The instant the output port is pressed, every input that could take the wire shows a ring, so the user has something to aim for before they have chosen. The wire’s end is sampled from the same arc-length table as the pointer, so the line never lags or leads the hand. At 80% of the way the pointer is inside the catch radius and the wire stops following: its end jumps the last fifth onto the port in 120ms on ease-out while the hand is still slowing down, and the caught ring closes onto its port as the other one withdraws. That is the snap, and it is only a preview. The wire and both ports stay neutral until pointer-up, then take clay together in 192ms on the same beat as the status, because a user who carries on past the port and lets go elsewhere must never have seen a link that was not made. Reach for it in flow builders, pipeline and automation editors, and anywhere two things are joined by dragging 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>Wire — drag to connect</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, shared with the refused variant (1% = 48ms). Press at 288ms,
a 1.15s drag, the snap 768ms in, release at 1.68s, and a long hold
on the committed link before the reset. */
--cycle: 4.8s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
--_ink: color-mix(in srgb, var(--slate) 80%, transparent);
--_wire: color-mix(in oklch, var(--slate) 38%, var(--paper));
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
display: grid;
place-items: center;
padding: clamp(10px, 3vw, 28px);
background: var(--ivory);
font-family:
system-ui,
-apple-system,
'Segoe UI',
Roboto,
sans-serif;
}
.card {
width: min(380px, 92vw);
border: 1px solid var(--oat);
border-radius: calc(14px * var(--round));
background: var(--paper);
}
.card svg {
display: block;
width: 100%;
height: auto;
}
/* Nodes are pills, so their radius stays literal and never takes --round. */
.node rect {
fill: var(--ivory);
stroke: var(--oat);
stroke-width: 1;
}
.node text,
.status text {
font-size: 12.5px;
font-weight: 500;
fill: var(--_ink);
}
.node text {
text-anchor: middle;
}
.drag,
.commit {
fill: none;
stroke-width: 2;
stroke-linecap: round;
}
/* The wire under the pointer. Its end is sampled from the same arc-length
table as the pointer below, one keyframe per 96ms, so the two cannot
drift apart; between samples both run linear. */
.drag {
stroke: var(--_wire);
stroke-dasharray: 100 200;
animation: drag var(--t) infinite linear;
}
/* The snap. At 80% of the way the pointer is 24 units out — inside the
port's catch radius — and the wire stops following the hand: its end
jumps the last fifth in 120ms on ease-out while the pointer is still
decelerating. From here the hand is free and the wire is anchored. */
@keyframes drag {
0%,
9% {
stroke-dashoffset: 100;
opacity: 1;
}
11% {
stroke-dashoffset: 98.89;
}
13% {
stroke-dashoffset: 94.63;
}
15% {
stroke-dashoffset: 84.88;
}
17% {
stroke-dashoffset: 67.3;
}
19% {
stroke-dashoffset: 47.93;
}
21% {
stroke-dashoffset: 34.05;
}
23% {
stroke-dashoffset: 24.92;
}
25% {
stroke-dashoffset: 18.86;
animation-timing-function: var(--ease-out);
}
27.5%,
84% {
stroke-dashoffset: 0;
opacity: 1;
animation-timing-function: ease;
}
90% {
stroke-dashoffset: 0;
opacity: 0;
}
90.01%,
100% {
stroke-dashoffset: 100;
opacity: 0;
}
}
/* Snapping is a preview; releasing is the commit. The wire only takes
colour on pointer-up, so a user who drags on past the port and lets go
somewhere else never sees a link that was never made. */
.commit {
stroke: var(--clay);
opacity: 0;
animation: commit var(--t) infinite;
}
@keyframes commit {
0%,
35% {
opacity: 0;
animation-timing-function: ease;
}
39%,
84% {
opacity: 1;
animation-timing-function: ease;
}
90%,
100% {
opacity: 0;
}
}
.port {
fill: var(--_wire);
stroke: var(--paper);
stroke-width: 1.5;
transform-box: fill-box;
transform-origin: center;
}
.port.src {
animation: src var(--t) infinite;
}
@keyframes src {
0%,
6% {
fill: var(--_wire);
transform: scale(1);
animation-timing-function: var(--ease-out);
}
8.5% {
transform: scale(1.3);
animation-timing-function: var(--ease-out);
}
12%,
35% {
fill: var(--_wire);
transform: scale(1);
animation-timing-function: ease;
}
39%,
84% {
fill: var(--clay);
animation-timing-function: ease;
}
90%,
100% {
fill: var(--_wire);
}
}
.port.dst {
animation: dst var(--t) infinite;
}
@keyframes dst {
0%,
35% {
fill: var(--_wire);
animation-timing-function: ease;
}
39%,
84% {
fill: var(--clay);
animation-timing-function: ease;
}
90%,
100% {
fill: var(--_wire);
}
}
/* Every port that could take this wire announces itself the moment the
drag starts, before the pointer has chosen — a target you can see from
the start is a target you can aim for. */
.halo {
fill: none;
stroke: var(--clay);
stroke-width: 1.25;
opacity: 0;
transform-box: fill-box;
transform-origin: center;
}
.halo.other {
animation: halo-other var(--t) infinite;
}
@keyframes halo-other {
0%,
9% {
opacity: 0;
transform: scale(0.8);
animation-timing-function: var(--ease-out);
}
12%,
25% {
opacity: 0.6;
transform: scale(1);
animation-timing-function: ease;
}
29%,
100% {
opacity: 0;
transform: scale(1);
}
}
/* The caught port's ring closes onto it on the snap frame: the catch is
drawn as the target taking hold, not as the line arriving. */
.halo.caught {
animation: halo-caught var(--t) infinite;
}
@keyframes halo-caught {
0%,
9% {
opacity: 0;
transform: scale(0.8);
animation-timing-function: var(--ease-out);
}
12%,
25% {
opacity: 0.6;
transform: scale(1);
animation-timing-function: var(--ease-out);
}
27.5%,
35% {
opacity: 1;
transform: scale(0.62);
animation-timing-function: ease;
}
38%,
100% {
opacity: 0;
transform: scale(0.62);
}
}
.pointer {
opacity: 0;
animation: pointer var(--t) infinite linear;
}
.pointer path {
fill: var(--slate);
stroke: var(--paper);
stroke-width: 1.25;
stroke-linejoin: round;
}
/* Pointer tip at the origin, so every translate is the tip's position
and the press scales about the point of contact. */
@keyframes pointer {
0%,
2% {
opacity: 0;
transform: translate(102px, 97px) scale(1);
animation-timing-function: var(--ease-out);
}
6% {
opacity: 1;
transform: translate(92px, 85px) scale(1);
animation-timing-function: var(--ease-out);
}
8.5% {
transform: translate(92px, 85px) scale(0.9);
animation-timing-function: linear;
}
9% {
transform: translate(92px, 85px) scale(0.9);
}
11% {
transform: translate(93.5px, 85px) scale(0.9);
}
13% {
transform: translate(98.9px, 85.2px) scale(0.9);
}
15% {
transform: translate(111.3px, 87px) scale(0.9);
}
17% {
transform: translate(132.1px, 95.4px) scale(0.9);
}
19% {
transform: translate(152.1px, 110.2px) scale(0.9);
}
21% {
transform: translate(166.4px, 120.7px) scale(0.9);
}
23% {
transform: translate(176.8px, 126.1px) scale(0.9);
}
25% {
transform: translate(184.1px, 128.8px) scale(0.9);
}
27% {
transform: translate(189.2px, 130.1px) scale(0.9);
}
29% {
transform: translate(192.4px, 130.7px) scale(0.9);
}
31% {
transform: translate(194.3px, 131px) scale(0.9);
}
33% {
opacity: 1;
transform: translate(195.1px, 131.1px) scale(0.9);
}
35% {
opacity: 1;
transform: translate(195.1px, 131.1px) scale(0.9);
animation-timing-function: var(--ease-out);
}
38%,
100% {
opacity: 0;
transform: translate(198px, 127px) scale(1);
}
}
/* Each label is out for 96ms before the next is in, with a 32ms gap,
so two states never share a frame at half opacity. The status flips on
release, with the colour, never on the snap. */
.s-idle {
animation: s-idle var(--t) infinite;
}
.s-done {
animation: s-done var(--t) infinite;
}
@keyframes s-idle {
0%,
35% {
opacity: 1;
animation-timing-function: ease;
}
37%,
86.67% {
opacity: 0;
animation-timing-function: ease;
}
89.5%,
100% {
opacity: 1;
}
}
@keyframes s-done {
0%,
37.67% {
opacity: 0;
animation-timing-function: ease;
}
40.5%,
84% {
opacity: 1;
animation-timing-function: ease;
}
86%,
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
/* The same score at half speed. The pointer and the travelling end
are removed; the wire fades in whole over the drag's own window, and
the snap, the commit colour and the status keep their beats. */
:root {
--t: calc(var(--cycle) * 2 / var(--speed));
}
.pointer {
animation: none;
opacity: 0;
}
.port.src {
animation-name: src-calm;
}
@keyframes src-calm {
0%,
35% {
fill: var(--_wire);
animation-timing-function: ease;
}
39%,
84% {
fill: var(--clay);
animation-timing-function: ease;
}
90%,
100% {
fill: var(--_wire);
}
}
.drag {
stroke-dasharray: none;
animation-name: drag-calm;
animation-timing-function: ease;
}
@keyframes drag-calm {
0%,
9% {
opacity: 0;
animation-timing-function: ease;
}
27.5%,
84% {
opacity: 1;
animation-timing-function: ease;
}
90%,
100% {
opacity: 0;
}
}
}
</style>
</head>
<body>
<div class="card">
<svg
viewBox="0 0 300 160"
role="img"
aria-label="A pointer presses the output port of an Intake node and drags a wire toward two input ports, both of which show a ring as the drag starts; near Benefits the wire snaps onto its port ahead of the pointer, and on release the wire turns solid and the status reads Linked to Benefits"
>
<g class="status">
<text class="s-idle" x="14" y="36">Drag to connect</text>
<text class="s-done" x="14" y="36">Linked to Benefits</text>
</g>
<g class="node">
<rect x="12" y="69" width="80" height="32" rx="16" />
<text x="52" y="89.5">Intake</text>
</g>
<g class="node">
<rect x="208" y="22" width="80" height="32" rx="16" />
<text x="248" y="42.5">Housing</text>
</g>
<g class="node">
<rect x="208" y="116" width="80" height="32" rx="16" />
<text x="248" y="136.5">Benefits</text>
</g>
<path class="drag" pathLength="100" d="M 92 85 C 150 85, 150 132, 208 132" />
<path class="commit" d="M 92 85 C 150 85, 150 132, 208 132" />
<circle class="halo other" cx="208" cy="38" r="9" />
<circle class="halo caught" cx="208" cy="132" r="9" />
<circle class="port src" cx="92" cy="85" r="4" />
<circle class="port" cx="208" cy="38" r="4" />
<circle class="port dst" cx="208" cy="132" r="4" />
<g class="pointer">
<path d="M0 0 L0 13.5 L3.6 10.2 L6.2 15.6 L8.6 14.5 L6 9.2 L10.8 9.2 Z" />
</g>
</svg>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.