Installation
Add the component
npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/button.jsonFirst component? Set up your project first
Frameworks
The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.
"use client";
import * as React from "react";
import { motion, type HTMLMotionProps, type Transition } from "motion/react";
import { cn } from "@/lib/utils";
import {
Slot,
pressSpring,
useReduceMotion,
useTempoTransition,
} from "./motion";
export type ButtonProps = HTMLMotionProps<"button"> & {
asChild?: boolean;
hoverScale?: number;
tapScale?: number;
transition?: Transition;
};
const BASE =
"inline-flex h-10 items-center justify-center gap-2 rounded-lg bg-primary px-4 text-[13px] font-medium text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50";
export function Button({
asChild = false,
hoverScale = 1,
tapScale = 0.97,
transition,
className,
...props
}: ButtonProps) {
const reduce = useReduceMotion();
const spring = useTempoTransition(transition ?? pressSpring);
const motionProps = {
"data-slot": "button",
initial: reduce ? undefined : { scale: 1 },
whileTap: reduce ? undefined : { scale: tapScale },
whileHover: reduce || hoverScale === 1 ? undefined : { scale: hoverScale },
transition: spring,
className: cn(BASE, className),
} as const;
if (asChild) {
return (
<Slot className={className} {...(props as React.HTMLAttributes<HTMLElement>)}>
{props.children as React.ReactNode}
</Slot>
);
}
return <motion.button {...motionProps} {...props} />;
}Install
npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/button.jsonDependencies
motion lucide-reactThe registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.
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 { Button } from "@/components/prequelui/button";
export default function Demo() {
return (
<Button tapScale={0.97} onClick={() => console.log("pressed")}>
Get started
</Button>
);
}import { Button } from "@/components/prequelui/button";
export function Variant() {
return (
<Button tempo={1.2}>
…
</Button>
);
}Animation
The button answers a press and nothing else. It moves to 97% of its size on the same spring every time, then returns to rest; hover only changes colour unless a hover scale is explicitly requested.
- Press spring: stiffness 550, damping 30, restSpeed 10.
- Hover scale defaults to 1, so the button never grows under the pointer.
- Repeated presses retarget the running spring instead of queueing.
- Reduced motion removes the press scale and keeps the colour change.
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.