Back to ButtonsYou are on Button.

Button

A button that presses down and never fidgets on hover.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks
PrequelUI

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

Fade in place
button.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/button.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/button.json
npmthe default on every machine

First 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.

5 runtimes
button.tsx
"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.json
npmthe default on every machine

Dependencies

motion lucide-react

The 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.

02

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.

button.tsx
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>
  );
}
03

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.
spring 550 / 30tap scale 0.97restSpeed 10hover colour only
04

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.

Button

PropTypeDefault
tapScalenumber0.97
hoverScalenumber1
asChildbooleanfalse
transitionTransitioncomponent spring or tween
classNamestring—

Next component

Copy Button

Copies text and swaps its icon in a quick blur crossfade.