Skip to main content
ExodeUI

EXODEUI DESKTOP

A little space for good ideas.

Choose your platform to get the official ExodeUI installer.

Looking for Intel Mac or other builds? Explore the web studio or check all download options.

Prefer the browser? Try for free in your browser →
Micro-interactions4 min read

Spring Action Button with Haptic Velocity

Direct Definition & Architecture

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.

Live .bexode760 × 380

Press and hold the button, then release.

Live inputs

Technical Specifications

Scene format
One .exode file
Live inputs
label, stiffness, damping, accent
Emitted event
press
Runtime targets
React, Vue, Svelte, SwiftUI

Interaction Phases

IdleRest scale with a soft accent glow and a faint grid.
PressedPointer down compresses the pill and removes elevation.
Spring backRelease injects velocity; stiffness and damping decide the rebound.
HoverThe pill tilts a few pixels toward the cursor without moving layout.

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

spring-button.jsx
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.

Try for free