Flip Button

A button that turns over on hover to reveal its back face.

flip-button.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/flip-button.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/flip-button.json

3

Turn on the motion

npx @prequelui/cli@latest animate flip-button

The CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

flip-button.tsx
import { FlipButton, FlipButtonBack, FlipButtonFront } from "@/components/prequelui/flip-button";

export default function Demo() {
  return (
    <FlipButton from="top">
      <FlipButtonFront>Hover me</FlipButtonFront>
      <FlipButtonBack>Let&apos;s go</FlipButtonBack>
    </FlipButton>
  );
}
import { FlipButton } from "@/components/prequelui/flip-button";

export function Variant() {
  return (
    <FlipButton tempo={1.2}>
      …
    </FlipButton>
  );
}

Animation

The two faces share one grid cell. On hover the front rotates away by 90° and slides out while the back arrives from the opposite side; the direction comes from the `from` prop, so the same button can open from any edge.

  • Face spring: stiffness 280, damping 20.
  • Rotation is 90° around X for top/bottom and around Y for left/right.
  • Perspective is fixed at 1000 px on the root.
  • Reduced motion turns the faces into a plain crossfade.
spring 280 / 20rotation 90°perspective 1000offset 50%

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

FlipButton

PropTypeDefault
from"top" | "bottom" | "left" | "right""top"
tapScalenumber0.97
transitionTransitioncomponent spring or tween

FlipButtonFront / Back

PropTypeDefault
childrenReactNode—
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026