Back to ButtonsYou are on Shimmer Button.

Shimmer Button

One short pass of light crosses the button on hover, never an endless loop.

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

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

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

Installation

Installing for React·components/prequelui/shimmer-button.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/shimmer-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
shimmer-button.tsx
"use client";

import * as React from "react";
import { motion, type HTMLMotionProps } from "motion/react";
import { cn } from "@/lib/utils";
import { pressSpring, useReduceMotion, useTempoTransition } from "./motion";

export type ShimmerButtonProps = HTMLMotionProps<"button"> & {
  shimmerColor?: string;
  shimmerDuration?: number;
  shimmerDelay?: number;
  shimmer?: boolean;
  tapScale?: number;
};

const BASE =
  "relative inline-flex h-10 items-center justify-center overflow-hidden rounded-lg bg-primary px-4 text-[13px] font-medium text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50";

export function ShimmerButton({
  shimmerColor = "color-mix(in oklab, var(--primary-foreground) 55%, transparent)",
  shimmerDuration = 900,
  shimmerDelay = 60,
  shimmer = true,
  tapScale = 0.97,
  className,
  children,
  onPointerEnter,
  onClick,
  ...props
}: ShimmerButtonProps) {
  const reduce = useReduceMotion();
  const spring = useTempoTransition(pressSpring);
  const [run, setRun] = React.useState(0);
  const timer = React.useRef<number | undefined>(undefined);

  React.useEffect(() => {
    return () => {
      if (timer.current !== undefined) window.clearTimeout(timer.current);
    };
  }, []);

  const play = React.useCallback(
    (delay = shimmerDelay) => {
      if (!shimmer || reduce) return;
      if (timer.current !== undefined) window.clearTimeout(timer.current);
      timer.current = window.setTimeout(() => {
        setRun((value) => value + 1);
      }, delay);
    },
    [reduce, shimmer, shimmerDelay],
  );

  const overlay =
    shimmer && run > 0 ? (
      <motion.span
        key={run}
        aria-hidden="true"
        data-slot="shimmer-button-beam"
        initial={{ x: "-180%", skewX: -14, opacity: 0 }}
        animate={{ x: "260%", skewX: -14, opacity: [0, 1, 1, 0] }}
        transition={{
          duration: shimmerDuration / 1000,
          ease: [0.33, 0, 0.2, 1],
          times: [0, 0.16, 0.72, 1],
        }}
        className="pointer-events-none absolute inset-y-0 left-0 z-0 w-[52%]"
        style={{
          background: `linear-gradient(105deg, transparent 0%, ${shimmerColor} 50%, transparent 100%)`,
        }}
      />
    ) : null;

  return (
    <motion.button
      data-slot="shimmer-button"
      whileTap={reduce ? undefined : { scale: tapScale }}
      transition={spring}
      onPointerEnter={(event) => {
        onPointerEnter?.(event);
        if (event.pointerType !== "touch") play();
      }}
      onClick={(event) => {
        onClick?.(event);
        play(0);
      }}
      className={cn(BASE, className)}
      {...props}
    >
      {overlay}
      <span className="relative z-10 inline-flex items-center gap-2">
        {children as React.ReactNode}
      </span>
    </motion.button>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/shimmer-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.

shimmer-button.tsx
import { ShimmerButton } from "@/components/prequelui/shimmer-button";

export default function Demo() {
  return (
    <ShimmerButton onClick={() => console.log("created")}>
      Create workspace
    </ShimmerButton>
  );
}
import { ShimmerButton } from "@/components/prequelui/shimmer-button";

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

Animation

A narrow band of light crosses the button once per hover. It does not loop: the pass is a single answer to the pointer, then the surface returns to rest. A click replays a shorter pass from the same edge.

  • Beam travel: 900 ms, from -180% to 260%, with a 14° skew.
  • Opacity follows 0 → 1 → 1 → 0 at 0 / 16 / 72 / 100 % of the pass.
  • Hover waits 60 ms before firing so a fast pass does not flicker.
  • Press spring: 550 / 30 to a 0.97 scale.
  • Reduced motion removes the beam and the press scale.
beam 900 msskew −14°delay 60 mspress 550 / 30
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.

ShimmerButton

PropTypeDefault
shimmerbooleantrue
shimmerColorstringprimary-foreground / 55%
shimmerDurationnumber900
shimmerDelaynumber60
tapScalenumber0.97
classNamestring—

Next component

Theme Toggler Button

A theme button whose icon spins, shrinks and blurs away.