A button that turns over on hover to reveal its back face.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/flip-button.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/flip-button.json
Turn on the motion
npx @prequelui/cli@latest animate flip-buttonThe 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.
import { FlipButton, FlipButtonBack, FlipButtonFront } from "@/components/prequelui/flip-button";
export default function Demo() {
return (
<FlipButton from="top">
<FlipButtonFront>Hover me</FlipButtonFront>
<FlipButtonBack>Let'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.
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.