Performance
Needs attentionFrame rate: 60 fps average, p5 59.5 · Long tasks: 0 tasks, 0 ms total, longest 0 ms · Source gzip 9.6 KB · Runtime 161 KB
Slosh sliderMITPatternBencho
A pattern React component by Lorenzo Cabra. Collected unchanged from Bencho under the MIT licence and shown here live.
Quality report
The grade and score come from automated checks run at build or test time. If a check did not run, it is marked Not tested — numbers are never invented.
Frame rate: 60 fps average, p5 59.5 · Long tasks: 0 tasks, 0 ms total, longest 0 ms · Source gzip 9.6 KB · Runtime 161 KB
Issues 0 · Screen reader: Pass
No continuous motion
No overflow
Frame rate and long-task figures were measured in headless Chromium with software WebGL. They are only comparable between components on this site, and do not represent real devices.
Not applicable: no visible animation at rest. Hover-triggered animation was not tested.
No axe-core violations.

Checked Nov 15, 2026 · Figures come from an automated script, not from hand-written samples.
Shown at real size.
The copy starts with the licence notice. Keep it when you use the code.
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* Slosh.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── flat panes ────────────────────────────────────────────
Set data-surface="flat" on any ancestor and every glass
surface under it becomes a solid fill with a hairline. The
inner buttons already sit on rgba(var(--ink-rgb), 0.05)
with no border, which is what flat wants anyway, so they
need nothing.
The frost is switched off at the element rather than through
a token. A var() holding a url() filter cannot be validated
at parse time, so the browser would treat it as invalid at
computed-value time and drop the property outright — which
breaks the two-declaration fallback the glass depends on. */
/* ══ stroke ═════════════════════════════════════════════════
Whether a component draws a hairline round itself. OFF by
default, which is the change: every glass surface carried
one unconditionally, and a grey line round everything makes
a wall of components look like a wall of boxes rather than
a wall of things.
The line is not load-bearing. A flat pane is a fill against
a different fill and reads on its own; the ring was there
to sharpen an edge that was already there.
Placed ABOVE the glass rules on purpose. Glass draws its
own lit rim, and that rim is the material rather than a
stroke — it is what gives a pane thickness. So glass wins
the border wherever the two meet, and Stroke governs the
drawn line that flat surfaces would otherwise have. */
[data-stroke="on"] .lab::before,
[data-stroke="on"] .gcard::before,
[data-stroke="on"] .gpane::before,
[data-stroke="on"] .gnav::before,
[data-stroke="on"] .gdock::before,
/* the playful blocks. None of them is glass, so none has a
lit rim for the stroke to lose to — the hairline is the
only edge they can have, and it is the whole of what this
control does for them. */
[data-stroke="on"] .esc-btn::before,
[data-stroke="on"] .slo-track::before,
[data-stroke="on"] .sek-skin::before {
border-color: var(--pane-edge);}
/* ══ playful blocks ═════════════════════════════════════════
Escape, Slosh, Shy. The behaviour is the joke and
the material is not in on it — these use the same ink, the
same wells and the same corners as everything else on the
bench. A block that announces it is being funny is not.
Every one of them is sized here rather than by whatever
holds it: the wall measures a component and scales it, the
canvas packs a declared footprint, and both need something
to measure. Escape in particular needs a real box, because
"it can never leave its own container" is a promise about a
specific number of pixels. */
.ply {
position: relative;
box-sizing: border-box;
font-family: var(--font-ui);
color: var(--ink);}
/* The field the two buttons move inside, and it paints
nothing at all.
It was a grey well, on the reasoning that an invisible
boundary reads as the button sticking. That reasoning was
right about a SMALL boundary and wrong about the component:
a 300x160 box put the clamp about fifty pixels from home in
every direction, so the button hit the wall constantly and
the wall had to be drawn to explain itself. Draw the wall
and you have also drawn a widget sitting in a box, which is
the one thing on this bench that has a frame round it.
Bigger, and the problem goes away rather than needing to be
explained: at 360x240 the clamp is over a hundred pixels
out and the button almost never reaches it. What is left is
a button on the page with room to bolt across, which is
what it always should have been. The box still EXISTS —
it is the layout box the travel is clamped to and the fixed
centre both blocks measure home from — it simply has no
surface. */
.ply-field {
width: 360px;
height: 240px;
display: grid;
place-items: center;}
/* Escape's field at the 300 standard block width; Slosh keeps its own */
.ply-field.esc { width: 300px; }
/* the hairline, hung on a ::before like every other stroke on
the bench — transparent until Stroke says otherwise */
.esc-btn::before,
.slo-track::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
border: 1px solid transparent;
pointer-events: none;}
/* ── 3 · Slosh ────────────────────────────────────────────
No transitions anywhere in here. Every value on this block
is written by the loop, and a transition on top of a spring
is two opinions about the same number. */
/* ── Slosh ──────────────────────────────────────────────────
THE READOUT AND THE TRACK ARE ONE SURFACE, and that is a
correctness fix rather than a look.
The number used to sit on the card with only the track
carrying the fill, and Fill redeclares the ink tokens for
everything inside it — so a light fill in the dark theme
gave the readout dark ink standing on a dark card, and the
reverse in the other direction. The text simply vanished.
A token that describes a surface has to be read BY things
on that surface. Putting the whole block on the fill makes
that true by construction, instead of by everybody
remembering which half of a component the fill applies
to. */
/* No card. The card existed to hold a label and a number
above the track, and with those gone it was a box drawn
round a single control. */
.slo {
box-sizing: border-box;
width: 320px;
font-family: var(--font-ui);}
/* ── THE WELL IS GREY, THE LIQUID IS WHITE ──────────────────
Which is the way round it should have been from the start.
I had the track white and the liquid a grey wash on top of
it, and that makes the part that MOVES the recessive one —
so the eye reads the still white remainder as the object and
the travelling grey as its ground. Backwards.
The back is a well now, and the thing sliding inside it is
the bright surface. No shadow on either: the well is darker
than the card it is cut into, which is the whole of how a
recess reads, and a recess with a drop shadow is a hole that
is somehow also on top. Stroke still has its hairline. */
.slo-track {
position: relative;
height: 40px;
border-radius: var(--slo-r, 14px);
/* ── OPAQUE, AND MIXED FROM THE FILL'S OWN PAIR ──────────
It was rgba(ink, 0.09) — a WASH, which means its result
depends on whatever happens to be behind it. With a light
Fill on the dark theme that is dark ink over a dark stage:
the well came out a shade of the background and vanished,
leaving the white slider floating with nothing around it.
A mix of the fill's ink into the fill's own slab is a real
colour rather than a veil, so the component looks the same
whatever it is standing on — which is the whole promise of
the Fill control. */
background: color-mix(in srgb,
var(--fill-on, var(--ink)) 11%, var(--fill-slab, var(--board)));
/* the fill leans past its own width at speed, and the track
is what stops the meniscus running off the end */
overflow: hidden;
cursor: ew-resize;
touch-action: none;}
.slo-track:focus-visible {
outline: none;
box-shadow: 0 0 0 2px var(--fill-slab, var(--bg)), 0 0 0 4px rgba(var(--fill-on-rgb, var(--ink-rgb)), 0.4);}
/* the liquid. The leading edge is slanted by a clip rather
than by a skew: a skew leans the whole body and the bottom
edge lifts off the floor of the track, which is a bar
tipping over rather than a surface with momentum in it. */
.slo-fill {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 62%;
/* the surface that travels, and it is the raised one */
background: var(--fill-slab, var(--board));
clip-path: polygon(
0 0,
calc(100% + var(--lean, 0px)) 0,
calc(100% - var(--lean, 0px)) 100%,
0 100%
);}
/* ── the same two roles, the ramp the other way up ──────────
In a dark fill the slab is already the floor, so the well IS
the slab and the slider is the lift off it. Both opaque and
both mixed from the same pair as the light case, so neither
is at the mercy of the stage behind it.
And the slider is a raised grey rather than a literal white:
it is two hundred pixels of solid colour, and a near-white
body that size on a near-black page is the brightest object
on the screen. That is the case --slab exists for, and the
answer is the same here — not the same end of the ramp in
both themes. */
[data-fill="dark"] .slo-track { background: var(--fill-slab); }
[data-fill="dark"] .slo-fill {
background: color-mix(in srgb, var(--fill-on) 15%, var(--fill-slab));}
/* the handle, which is rigid and under your finger. Thin on
purpose — it is a reading of where you are, and the fill is
the thing with the mass. */
.slo-knob {
position: absolute;
top: 6px;
bottom: 6px;
left: 62%;
width: 3px;
margin-left: -1.5px;
border-radius: 999px;
background: var(--fill-on, var(--ink));
pointer-events: none;}
// bencho source (MIT). npm i motion react · Tailwind CSS v4
// ── blocks/slosh/Slosh.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/slosh/Slosh.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { useEffect, useRef } from "react";
/* ══ playful blocks ═══════════════════════════════════════
Two components whose behaviour is the joke. The material
stays as quiet as everything else on this bench — no
confetti, no exclamation marks, no sound. If the decoration
is doing the work then the interaction is not.
THE JOKE HAS TO RESOLVE. A button that never lets itself be
clicked is friction with a smirk on it. A button that
dodges four times and then gives up is a small story with
an ending, and the ending is the reason it is worth
shipping rather than a garnish on top of one.
Which makes one rule absolute here: none of these may trap
anybody. Every one of them completes, every one of them
completes within a few seconds, and every one of them
completes from the keyboard on the first try — the tease is
a pointer phenomenon and a person who is not using a
pointer is not the audience for it. */
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
/* Read once, like the wheel and the pill nav do. This is a
preference, not a live input — a person who changes it
mid-session gets it on the next render of the page, which
is soon enough and costs nothing to be wrong about. */
const still = () =>
typeof window !== "undefined" &&
!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/* ══ 3 · Slosh ════════════════════════════════════════════
A slider whose value has mass.
The handle is rigid — it is under your finger and anything
under a finger that lags it is broken. The FILL is a second
spring behind it, softer and barely damped, so a fast drag
throws it past the handle, into the end stop, and rocks it
back two or three times before it settles. Release halfway
and the handle coasts on the velocity it actually had
rather than stopping dead where you let go.
The tilt is what sells it as liquid. A bar that lags is a
laggy bar; a bar whose leading edge leans in the direction
it is travelling is a surface with a meniscus on it. Same
lag, entirely different object.
Nothing here goes through React. The loop writes width, a
custom property and one text node straight onto three
elements, and it stops the moment everything is at rest —
there is one permanent rAF on this bench already and
CLAUDE.md is not complimentary about it. */
/* the track's corner. 13 is what it was drawn at and 20 is
half of its 40px height — the pill, which is as round as a
40px track can be. The knob inside stays a circle: it is a
ball in a slot, and a square ball is a different object. */
const SLO_CORNER = 20;
const SLO_MAX = 20;
export function Slosh({
/* 0 is a rigid fill, 100 is loose liquid. 15 is a fill with
a little give rather than a wave in a glass — at 40 the
surface was the loudest thing on a block whose subject is
the value being set. */
viscosity = 15,
/* how far it coasts after release, 0..100 */
momentum = 55,
/* lean on the leading edge, 0..100 */
tilt = 45,
/* the corner it is cut with */
corner = SLO_CORNER,
}: {
viscosity?: number;
momentum?: number;
tilt?: number;
corner?: number;
} = {}) {
const track = useRef<HTMLDivElement | null>(null);
const fillEl = useRef<HTMLDivElement | null>(null);
const knobEl = useRef<HTMLDivElement | null>(null);
const reduced = still();
/* the handle, its velocity after release, and the fill
chasing it with a velocity of its own */
const val = useRef(62);
const hv = useRef(0);
const fill = useRef(62);
const fv = useRef(0);
const held = useRef(false);
const raf = useRef(0);
/* the last two samples, which is all a release velocity is */
const last = useRef({ v: 62, t: 0 });
/* live, so the loop reads what the panel is currently set
to without restarting on every drag of a knob */
const knobs = useRef({ viscosity, momentum, tilt, reduced });
knobs.current = { viscosity, momentum, tilt, reduced };
/* the loop parks itself when everything is at rest, so
every handler below needs a way to wake it back up */
const run = useRef<() => void>(() => {});
useEffect(() => {
const paint = () => {
const f = fillEl.current;
const k = knobEl.current;
const t = track.current;
if (!f || !k || !t) return;
f.style.width = `${fill.current.toFixed(2)}%`;
k.style.left = `${val.current.toFixed(2)}%`;
/* the meniscus. Proportional to how fast the fill is
actually moving, so it is upright at rest and cannot
be a decoration — there is nothing to decorate when
nothing is travelling. */
const lean = knobs.current.reduced
? 0
: clamp((knobs.current.tilt / 100) * fv.current * 3, -20, 20);
f.style.setProperty("--lean", `${lean.toFixed(2)}px`);
t.setAttribute("aria-valuenow", String(Math.round(val.current)));
};
const rest = () =>
!held.current &&
Math.abs(hv.current) < 0.01 &&
Math.abs(fv.current) < 0.01 &&
Math.abs(val.current - fill.current) < 0.02;
let prev = 0;
const tick = (t: number) => {
const dt = prev ? clamp((t - prev) / 16.67, 0, 2.5) : 1;
prev = t;
const { viscosity: v, momentum: m, reduced: flat } = knobs.current;
/* the coast. Friction is per frame, so it is raised to
dt rather than multiplied by it — a dropped frame must
not double the deceleration. */
if (!held.current && hv.current) {
val.current += hv.current * dt;
hv.current *= Math.pow(0.86 + (m / 100) * 0.115, dt);
if (val.current <= 0 || val.current >= 100) {
val.current = clamp(val.current, 0, 100);
hv.current = 0;
}
if (Math.abs(hv.current) < 0.01) hv.current = 0;
}
const soft = flat ? 0 : v / 100;
if (soft === 0) {
/* 0 is an ordinary slider and has to be exactly that,
not a very stiff spring that still rings */
fill.current = val.current;
fv.current = 0;
} else {
/* stiffness falls and damping rises together: thin
liquid is slow to answer and slow to forget, which
is the same thing said twice and is why these are
one knob rather than two */
const stiff = 0.34 - soft * 0.29;
const damp = 0.74 + soft * 0.22;
fv.current += (val.current - fill.current) * stiff * dt;
fv.current *= Math.pow(damp, dt);
fill.current += fv.current * dt;
/* the end stop is a wall, and a wall gives some back.
Without this the overshoot at the top of the track
is simply swallowed and the liquid stops behaving
like liquid exactly where you are looking at it. */
if (fill.current > 100) {
fill.current = 100;
fv.current = -fv.current * 0.42;
} else if (fill.current < 0) {
fill.current = 0;
fv.current = -fv.current * 0.42;
}
if (Math.abs(val.current - fill.current) < 0.02 && Math.abs(fv.current) < 0.02) {
fill.current = val.current;
fv.current = 0;
}
}
paint();
if (rest()) {
raf.current = 0;
prev = 0;
return;
}
raf.current = requestAnimationFrame(tick);
};
run.current = () => {
if (!raf.current) raf.current = requestAnimationFrame(tick);
};
paint();
return () => {
cancelAnimationFrame(raf.current);
raf.current = 0;
};
}, []);
/* offset maths, then divided by the zoom: the same rect the
canvas would skew, used only for its origin and its
scale */
const readAt = (clientX: number) => {
const t = track.current;
if (!t) return 0;
const box = t.getBoundingClientRect();
const k = box.width / (t.offsetWidth || box.width) || 1;
return clamp(((clientX - box.left) / k / t.offsetWidth) * 100, 0, 100);
};
const grab = (e: React.PointerEvent) => {
(e.target as Element).setPointerCapture?.(e.pointerId);
held.current = true;
hv.current = 0;
val.current = readAt(e.clientX);
last.current = { v: val.current, t: e.timeStamp };
run.current();
};
const move = (e: React.PointerEvent) => {
if (!held.current) return;
const v = readAt(e.clientX);
const dt = Math.max(1, e.timeStamp - last.current.t);
/* per frame, not per ms — the whole loop is in frames and
a release velocity in the other unit is a hundred times
too big */
hv.current = ((v - last.current.v) / dt) * 16.67;
last.current = { v, t: e.timeStamp };
val.current = v;
run.current();
};
const drop = () => {
if (!held.current) return;
held.current = false;
/* it leaves along the velocity it actually had, capped so
a flick across the whole track does not simply pin it */
hv.current = clamp(hv.current, -6, 6);
if (knobs.current.reduced) hv.current = 0;
run.current();
};
const key = (e: React.KeyboardEvent) => {
const step = e.shiftKey ? 10 : 2;
const to =
e.key === "ArrowRight" || e.key === "ArrowUp" ? val.current + step
: e.key === "ArrowLeft" || e.key === "ArrowDown" ? val.current - step
: e.key === "Home" ? 0
: e.key === "End" ? 100
: null;
if (to === null) return;
e.preventDefault();
hv.current = 0;
val.current = clamp(to, 0, 100);
run.current();
};
return (
<div
className="ply slo"
style={{ "--slo-r": `${clamp(corner, 0, SLO_MAX)}px` } as React.CSSProperties}
>
{/* ── NOTHING BUT THE TRACK ────────────────────────
There was a label and a big number over it, and the
number was the best argument for removing them: it
read the FILL rather than the handle, so it lagged
and overshot and rocked into place — a second telling
of the one thing the liquid is already saying, in
digits, louder than the thing itself.
The slosh is the component. A caption and a readout
bracketing a track is what every slider in every kit
looks like, and it was the only part of this one that
was. */}
<div
className="slo-track"
ref={track}
role="slider"
tabIndex={0}
aria-label="Flow"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={62}
onPointerDown={grab}
onPointerMove={move}
onPointerUp={drop}
onPointerCancel={drop}
onKeyDown={key}
>
<div className="slo-fill" ref={fillEl} />
<div className="slo-knob" ref={knobEl} />
</div>
</div>
);
}Controls · HTML · CSS · JS
Edit the code and tune it with the controls. The preview updates as you type.

This component runs from a bundled build, so its script is read-only here. Edit the HTML and CSS; the full source is in the Code tab.
Edit every component live, tune it with controls, download the full source and copy the advanced prompts.
$49 one-timePlaceholder price
Test mode: no real payment is taken.
Free: preview, copy buttons and the lesson notes.
A repeating motif adds texture without competing with the text.
Hero backgrounds, section dividers and empty areas.
Scale the tile size, lower the contrast and pick two colours.
Add the "Slosh slider" component from Bencho (github.com/cabralorenzo/bencho) (MIT) to my React + Tailwind CSS app. Source file: https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/slosh/Slosh.tsx. A repeating motif adds texture without competing with the text. Use it for: Hero backgrounds, section dividers and empty areas. Settings to tune: Scale the tile size, lower the contrast and pick two colours. Support light and dark themes and respect prefers-reduced-motion. Keep the MIT licence notice.
A longer prompt with tuning, accessibility and integration steps.