No.20 · Buttons
Slosh Button
A glass capsule partly full of liquid that sloshes the other way when you move across it, rocking back and forth before it settles; press it and it fills to the brim, the label inverting at the waterline.
The prompt
Written for the variant you picked above: Night
Build a toggle button (56px pill) made of glass: faint fill, hairline ring, inner top highlight and a soft glass sheen above everything. Inside, an SVG liquid body drawn every frame: a surface line sampled at 25 points, y = base + tilt × (x − w/2) + a small sine wave, closed down to the bottom. A thin white meniscus strokes the surface. Simulate two springs in one requestAnimationFrame loop that stops when settled: the level (resting 30%, 50% while hovered, 112% when pressed on) and the tilt, an underdamped spring (k 70, damping 3.2) so it rocks several times. Pointer movement feeds the tilt's velocity in proportion to the pointer's horizontal speed, so the liquid piles up on the side you came from and then rocks back; the wave's amplitude grows with how fast it's rocking. Toggling on pours it to the brim with a little jolt. Render the label twice in the same box: cream on the glass and ink above it, the ink copy clipped each frame with clip-path: path() using the same liquid outline, so the label inverts exactly along the moving surface. It's a toggle: aria-pressed, 'Save for later' → '✓ Saved'. Selected variant — Night (night): Palette for this theme (Night): --slb-edge rgb(239 232 220 / 0.22); --slb-glass rgb(255 255 255 / 0.05); --slb-ink #efe8dc; --slb-ink-on #0e1420; --slb-liquid #b9cce4; --slb-shine rgb(255 255 255 / 0.7). Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "night". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Move across it to make the liquid slosh; hover tops it up; click to fill it and save, click again to empty. Motion: Level spring (k 40, c 9); tilt spring (k 70, c 3.2), clamped to ±0.32; surface ripple speeds up while hovered. Accessibility: A real toggle button with aria-pressed and a label that changes to 'Saved'; the liquid and the ink copy are aria-hidden. Works fully from the keyboard; focus shows an outline. Reduced motion jumps to the level without sloshing. Responsive behavior: Measured with a ResizeObserver, so the liquid fits any label. Touch: Tapping fills or empties it with a slosh. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Move across it to make the liquid slosh; hover tops it up; click to fill it and save, click again to empty.
- Motion
- Level spring (k 40, c 9); tilt spring (k 70, c 3.2), clamped to ±0.32; surface ripple speeds up while hovered.
- Accessibility
- A real toggle button with aria-pressed and a label that changes to 'Saved'; the liquid and the ink copy are aria-hidden. Works fully from the keyboard; focus shows an outline. Reduced motion jumps to the level without sloshing.
- Responsive
- Measured with a ResizeObserver, so the liquid fits any label.
- On touch
- Tapping fills or empties it with a slosh.