REFERENCE
- Gallery page: https://magpui.com/en/i/rubber-duck-bath-temperature-slider-5c28fc
- First frame (image): https://dnioievkvxejjbxgwvko.supabase.co/storage/v1/object/public/media/rubber-duck-bath-temperature-slider-5c28fc/shot.jpg
- Clip (mp4): https://dnioievkvxejjbxgwvko.supabase.co/storage/v1/object/public/media/rubber-duck-bath-temperature-slider-5c28fc/clip.mp4
- Original post: https://x.com/techartist_/status/2120752319243723236 by @techartist_
Before building, download the first frame and look at it. If ffmpeg is available, download the clip and extract frames (ffmpeg -i clip.mp4 -vf fps=2 frame-%02d.png), then study the motion frame by frame. Match what you see; the text below describes it, the frames are the truth.
BUILD: A playful range input shaped like a bathtub seen from above at a slight angle. The thumb is a glossy yellow rubber duck floating in the water; the left end has a blue cold tap, the right end a red hot tap. Dragging the duck (or using arrow keys) changes the temperature from freezing to scalding. A small white pill above the duck shows the value and a word ("10°C freezing", "38°C just right", "90°C scalding"). The whole scene reacts: hot water steams and the page turns deep red, warm is clear aqua, cold turns the page navy and fills the tub with floating ice chunks. It should feel like a toy you want to keep pushing.
DESIGN SYSTEM: Full-viewport stage, tub centered at about 60% of the width, aspect ~2.3:1, thick white rim (#f2f1ee) with soft inner shadow and rounded stadium shape, radius = half the height. Water: caustic pattern in #7fdcf0 to #c8f4ff with bright white highlights. Duck: about 22% of tub height, #ffd93b body, #ff9e7a beak, glossy specular. Value pill: white, radius 999px, 12px text, number bold in a color that follows temperature (#e5484d hot, #2f80ed cold). Background radial gradients: hot #3a0a0a to #1a0505, warm #2a0f2f, cold #0c1a3a to #050b1e. Top-left title 14px bold #ffffff with a 11px subtitle #ffffff99; top-right round sound toggle 28px #ffffff1a. Helper line under the tub 12px #ffffffb3 with the first words bold.
MOTION:
- Drag: duck follows the pointer along the tub's long axis with spring physics (stiffness 220, damping 18), tilting up to 8deg in the direction of travel and bobbing 2px on a 1600ms sine.
- Temperature mapping: background gradient, water tint and caustic speed interpolate continuously; transitions eased over 400ms cubic-bezier(0.22, 1, 0.36, 1).
- Hot (>60°C): steam puffs rise from the water, 2-4s life, opacity 0 to 0.5 to 0, drifting up 120px; near the hot tap a spray of tiny white sparks/bubbles fans out while dragging there.
- Cold (<15°C): 6-10 white ice cubes fade and scale in from 0.6 to 1 over 500ms with 60ms stagger and drift slowly; caustics slow down.
- Pill: number tweens on change; the word swaps with a 150ms crossfade and 4px vertical slide.
- Release: duck settles with a small overshoot and ripples spread from it (two rings, 800ms, ease-out).
SECTIONS: Parts: stage background, tub rim, water, duck thumb, taps, value pill, steam and ice layers, helper text, sound toggle. States: idle, dragging, cold, warm/just right, hot, focus.
IMPLEMENTATION: Three.js or React Three Fiber for the tub, water plane (caustics shader with a temperature uniform) and the duck model; DOM for the pill, labels and a real visually-hidden input type=range that drives the value so it is accessible. Steam as instanced soft sprites, ice as instanced rounded boxes. Optional sound: water slosh on drag, sizzle when hot, clink when ice appears, muted by default. prefers-reduced-motion: no steam or ripples, instant tints, duck moves without spring. Keyboard: arrows step 1°C, Shift+arrows 10°C, visible focus ring around the duck. Cap devicePixelRatio at 2.
ADAPT TO THE PROJECT: Reuse the project's fonts and tokens and map the background tints to the nearest existing colors. Do not copy the original texts, branding or model; use a simple placeholder duck model or primitives.
SUCCESS CHECK:
- Dragging the duck or pressing arrow keys changes the value pill and the input value together.
- Hot values show steam and a red page; cold values show ice cubes and a navy page; the middle reads clear aqua.
- Releasing the duck shows a gentle overshoot and ripples, and reduced motion removes them.