Skip to main content

React animation example

React Animated Modal: Spring Pop-Up Dialog

A modal should come from somewhere. This dialog grows out of the button that opened it, scaling on a spring while the page behind it dims and shrinks slightly to push it back in space. Clicking the backdrop or the cancel button reverses the motion into the same button.

  • 4.5 KB file
  • 6 live inputs
  • React runtime
Live, try it

How this spring modal works

  • The dialog's origin is the trigger button's centre; scale and position spring from there to the middle.
  • The page behind scales to 96% and dims, which reads as depth without a heavy blur.
  • "confirm" and "dismiss" events fire from the two buttons; the open state is an input.

Add it to your React app

Install exodeui, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import { ExodeUICanvas } from 'exodeui';

// react-animated-modal.bexode goes in /public (download it below)
export function ReactAnimatedModal() {
  return (
    <ExodeUICanvas
      src="/react-animated-modal.bexode"
      fit="Layout"
      autoPlay
      interactive
      onTrigger={(name) => {
        // fires: 'confirm', 'dismiss'
      }}
      style={{ width: '100%', height: 520 }}
    />
  );
}

Inputs

InputTypeDefaultRange
openBooleanfalse—
headingTextDelete project?—
bodyTextThis removes the file for everyone on your team.—
accentText#ef4444hex colour
inkText#fafafahex colour
bgText#0c0c0ehex colour

Events: confirmdismiss

More React animations