Spring Action Button with Haptic Velocity
A spring button uses second-order differential physics equations rather than fixed cubic-bezier curves to calculate scale, displacement, and rebound. When pressed, energy accumulates; on release, momentum decays naturally based on stiffness and damping coefficients.
Technical Specifications
Interaction Phases
The scene keeps one Idle state. These phases are driven by its inputs and pointer events; the same values appear in the code below.
Use the scene
import { ExodeUICanvas } from 'exodeui';
// spring-button.bexode goes in /public
export function SpringButton() {
return (
<ExodeUICanvas
src="/examples/live/spring-button.bexode"
fit="Layout"
autoPlay
interactive
inputs={{
label: 'Deploy component',
stiffness: 340,
damping: 22,
accent: '#ff4a1c',
bg: '#f7f5f0',
ink: '#171310',
}}
onTrigger={(name) => {
// fires: 'press'
}}
style={{ width: '100%', height: 380 }}
/>
);
}This snippet loads /examples/live/spring-button.bexode with the same inputs shown in the live stage.
Architectural Breakdown
Unlike CSS transitions with fixed cubic-bezier curves, a physics-based spring button recalculates momentum dynamically on every pointer event.
If a user interrupts the release animation with another click, momentum transfers seamlessly into the subsequent compression stroke without unnatural jarring or resetting.
The scene stores the spring values as state-machine inputs, so stiffness and damping can change while the button is running.
Frequently Asked Questions
Explore Related Motion Guides & Tooling
Build your next living interface today.
Design fluid physics and visual logic in ExodeUI and export directly to React, Swift, and Flutter.