Click

A visual effect played where the pointer clicks: a ring, a ripple, a crosshair, a burst or particles.

Click anywhere in this area

"use client"

import * as React from "react"
import { cn } from "cn"
import {
  Click,
  type ClickVariant,
} from "@animate-ui/react/primitives/effects/click"

const VARIANTS: ClickVariant[] = [
  "ring",
  "ripple",
  "crosshair",
  "burst",
  "particles",
]

export default function ClickDemo({
  global = false,
  duration = 400,
  size = 100,
}: {
  global?: boolean
  duration?: number
  size?: number
}) {
  const scopeRef = React.useRef<HTMLDivElement>(null)
  const [variant, setVariant] = React.useState<ClickVariant>("ring")
  const scope = global ? undefined : scopeRef

  const area = (
    <p className="text-lg font-medium text-muted-foreground select-none">
      Click anywhere in this area
    </p>
  )

  return (
    <div className="flex w-full max-w-md flex-col gap-3">
      <div
        ref={scopeRef}
        className="flex h-56 items-center justify-center rounded-xl border border-dashed text-foreground"
      >
        {variant === "ripple" ? (
          <Click
            variant="ripple"
            scope={scope}
            color="var(--color-primary)"
            size={size}
            duration={duration}
          >
            {area}
          </Click>
        ) : (
          <Click
            variant={variant}
            scope={scope}
            color="currentColor"
            size={size}
            duration={duration}
          >
            {area}
          </Click>
        )}
      </div>
      <div
        role="radiogroup"
        aria-label="Variant"
        className="flex flex-wrap justify-center gap-1"
      >
        {VARIANTS.map((item) => (
          <button
            key={item}
            type="button"
            role="radio"
            aria-checked={variant === item}
            onClick={() => setVariant(item)}
            className={cn(
              "h-7 rounded-md px-2.5 text-xs font-medium capitalize transition-colors",
              variant === item
                ? "bg-accent text-foreground"
                : "text-muted-foreground hover:text-foreground"
            )}
          >
            {item}
          </button>
        ))}
      </div>
    </div>
  )
}

Installation

npm install @animate-ui/react motion
pnpm add @animate-ui/react motion
yarn add @animate-ui/react motion
bun add @animate-ui/react motion

Usage

import * as React from 'react';
import { Click } from '@animate-ui/react/primitives/effects/click';

export function Canvas() {
  const ref = React.useRef<HTMLDivElement>(null);

  return (
    <div ref={ref}>
      <Click scope={ref} variant="ring">
        <p>Click anywhere</p>
      </Click>
    </div>
  );
}

Without scope, every click on the page plays the effect.

Animation

  • On pointer up, the effect plays centered on the pointer, then is removed. It lasts duration (400ms by default); with variant="particles", the dots start one after another and finish a little later.
  • Effects render in a fixed layer over the page that never catches the pointer, so clicks still reach what's underneath.
  • Several clicks in a row each play their own effect.
  • Under reduced motion, no effect is played.

API Reference

Click

PropTypeDefault
variant?
'ring' | 'ripple' | 'crosshair' | 'burst' | 'particles''ring'
color?
string'currentColor'
size?
number100
duration?
number400
scope?
React.RefObject<HTMLElement | null>-
disabled?
booleanfalse
children?
React.ReactNode-

Credits

Built by Skyleen. The source code is available on GitHub.

Last updated: 10/18/2026

On this page