跪拜 Guibai
← All articles
Front-end · Interaction Design · CSS

Name the Physics: 12 UI Interactions and the AI Prompts That Reproduce Them

By ENCI ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A prompt that names a specific physics-based interaction, like press-bounce or elastic toggle, is what forces an AI model to produce convincing motion instead of a generic scale. This catalog gives AI-assisted UI work a vocabulary for tactile micro-interactions, along with working CSS and JS to ship the effect if the model misses.

Summary

The line between generic and advanced UI motion is physical feel. Pressing a button should compress it, then overshoot and settle; a toggle's thumb should stretch into a capsule before snapping back; ripples should start where your finger lands, not at the widget's center. All twelve effects in this guide simulate spring forces, inertia, friction, or material behavior, and each comes with a one-sentence prompt that tells an AI model exactly what to build.

The core advice: stop describing the desired visual and instead describe the physics. For a press bounce, say "scale to 0.92 on press, overshoot to 1.05 on release, then settle with a spring easing", not "add a bounce". The same precision applies to numbers that ease-out before stopping, skeletons that match real content height to prevent layout jumps, and a bottom sheet that pauses at half-screen. A runnable HTML/CSS demo shows four of the effects working, and a troubleshooting table maps common failures like a centered ripple or confetti on every button to the prompt fix that cures them.

Takeaways
— The difference between advanced and ordinary UI interaction is whether it simulates physical mechanics: spring, elasticity, friction, and inertia.
— Twelve interactions are covered: press bounce, elastic toggle, ripple from touch point, confetti burst, checkmark draw, liquid slider, easing number scroll, stable skeleton layout, card flip, hamburger morph, card stack peek, and bottom sheet hold.
— The prompt technique is to describe physical behavior rather than the visual end state; for example, specify 'on release it overshoots to 1.05 then settles to 1.0' instead of 'add a bounce'.
— A ripple effect must originate at the touch point, not the button center; the prompt should reference Material ripple to enforce this.
— Confetti should be used only for like or favorite actions, and the prompt must explicitly say 'only for likes and favorites' to prevent AI from adding it to every button.
— Skeleton placeholders must match the real content height to prevent layout jumps when data loads.
— A card flip should hide the front face at 90 degrees and show the back only after that, to avoid mirrored or see-through text.
— A hamburger menu must morph its same three lines into an X, not swap to a different icon, to keep the button's identity.
— A bottom sheet should pause at half-screen to give the user a decision point before snapping fully open or closed.
— The runnable HTML/CSS demo implements four effects: press bounce, ripple from touch point, checkmark draw, and hamburger morph, using CSS variables, stroke-dashoffset, and transform transitions.
— A troubleshooting table pairs each common failure (centered ripple, confetti everywhere, out-of-sync slider) with the prompt fix that addresses it.
Conclusions

The central claim that 'physical feel' separates advanced from ordinary interaction holds up: every effect maps to a real-world analogue like a silicone key, rubber band, pouring water, or turning over a playing card.

Specifying physical behavior over visual results is a generalizable lesson for AI-assisted coding; it turns a vague request like 'add animation' into a precise specification any model can act on.

The guide repeatedly warns against overusing effects: confetti for every button cheapens it, and the most important interaction may be the invisible one — a skeleton placeholder that prevents layout jumps. That restraint is framed as the highest form of quality, not the flashiest motion.

Concepts & terms
spring animation
A physics-based easing that overshoots the target value (like a rubber band) before settling, commonly used to make UI elements feel weighted and responsive.
Material ripple
Google's Material Design touch feedback: a circular ripple expands outward from the exact point of contact, giving the UI a sense of material and location.
stroke-dashoffset
An SVG/CSS technique that animates a line drawing by shifting the dash offset, used here to draw a checkmark stroke by stroke instead of popping it in whole.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗