Back to ButtonsYou are on Icon Button.

Icon Button

An icon button that releases a small burst of particles.

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

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

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

Installation

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

Add the component

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

import * as React from "react";
import { motion } from "motion/react";
import { cn } from "@/lib/utils";
import { Button, type ButtonProps } from "./button";
import { useReduceMotion } from "./motion";

type IconButtonContextValue = { bursts: number };

const IconButtonContext = React.createContext<IconButtonContextValue | null>(null);

export type IconButtonProps = ButtonProps;

export function IconButton({ onClick, className, ...props }: IconButtonProps) {
  const [bursts, setBursts] = React.useState(0);

  return (
    <IconButtonContext.Provider value={{ bursts }}>
      <Button
        data-slot="icon-button"
        onClick={(event) => {
          onClick?.(event);
          setBursts((value) => value + 1);
        }}
        className={cn(
          "relative size-10 border bg-background p-0 text-foreground hover:bg-accent",
          className,
        )}
        {...props}
      />
    </IconButtonContext.Provider>
  );
}

export type IconButtonParticlesProps = {
  size?: number;
  count?: number;
  distance?: number;
  className?: string;
};

export function IconButtonParticles({
  size = 4,
  count = 8,
  distance = 24,
  className,
}: IconButtonParticlesProps) {
  const context = React.useContext(IconButtonContext);
  const reduce = useReduceMotion();
  const bursts = context?.bursts ?? 0;

  return (
    <span
      data-slot="icon-button-particles"
      aria-hidden="true"
      className={cn("pointer-events-none absolute inset-0", className)}
    >
      {Array.from({ length: count }).map((_, index) => (
        <motion.span
          key={`${bursts}-${index}`}
          initial={{ opacity: 0, x: 0, y: 0, scale: 0.8 }}
          animate={
            bursts === 0 || reduce
              ? { opacity: 0 }
              : {
                  opacity: [1, 0],
                  x: Math.cos((index / count) * Math.PI * 2) * distance,
                  y: Math.sin((index / count) * Math.PI * 2) * distance,
                  scale: 0.2,
                }
          }
          transition={{ duration: 0.55, ease: [0.23, 1, 0.32, 1] }}
          className="absolute left-1/2 top-1/2 rounded-full bg-current"
          style={{ width: size, height: size }}
        />
      ))}
    </span>
  );
}

export function useIconButton() {
  const value = React.useContext(IconButtonContext);
  if (!value) throw new Error("useIconButton must be used inside IconButton");
  return value;
}

Install

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

icon-button.tsx
import { Bell } from "lucide-react";
import { IconButton, IconButtonParticles } from "@/components/prequelui/icon-button";

export default function Demo() {
  return (
    <IconButton aria-label="Notifications">
      <Bell className="size-4" />
      <IconButtonParticles />
    </IconButton>
  );
}
import { IconButton } from "@/components/prequelui/icon-button";

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

Animation

A press releases a small burst around the icon. Eight dots leave from the centre on evenly spaced angles, shrink and fade in 550 ms; the button keeps the shared press spring underneath.

  • Particles: 550 ms ease-out, 24 px travel, scale 0.8 → 0.2.
  • The burst is remounted for every press, so rapid clicks never overlap.
  • Particles are pointer-events none and aria-hidden.
  • Reduced motion emits no particles and keeps the press feedback.
particles 550 mstravel 24 px8 anglesaria-hidden
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.

IconButton

PropTypeDefault
childrenReactNode—
tapScalenumber0.97
classNamestring—

IconButtonParticles

PropTypeDefault
countnumber8
sizenumber4
distancenumber24

Next component

Liquid Button

A button that fills with liquid from the bottom on hover.