Click Pop
A small pop at the pointer on every click: burst, ring, particles, crosshair or wavy. Use it once in your layout, in a calm color, for the whole site.
npx shadcn@latest add https://impeccable-ui.com/r/click-pop.jsonRun it in a project set up with shadcn. No other packages needed. Or open and copy the file into components/ui/click-pop.tsx.
Types
Five types, each popping on its own in turn. Click a box to pop it yourself. Burst is the default: four short lines above the tip, the one this website uses. Ring and Crosshair are the calmest, Particles and Wavy the most playful.
<ClickPop type="burst" /> // four lines shoot out above the pointer tip
<ClickPop type="ring" /> // a thin ring opens around the click
<ClickPop type="particles" /> // eight dots scatter and drift down
<ClickPop type="crosshair" /> // four ticks swing in and lock on
<ClickPop type="wavy" /> // four lines wriggle out, then straightenPrompts
Paste one into Claude Code, Cursor or any AI coding tool. Install adds this exact pop and asks only where it goes. Blend asks four short questions (where, which type, the color and taps on phones), then fits it to your product without changing how it moves.
# Click Pop
A 1-file React component from Impeccable. Add it to this project so it works and looks exactly like the source below, in the one place I choose, and change nothing else.
A small pop at the pointer every time someone clicks, in one of five types: **burst** (four short lines shoot out above the pointer tip, shrink to dots and fade), **ring** (a thin ring opens around the click and fades), **particles** (eight dots scatter all around, drift down a little and fade), **crosshair** (four ticks swing in from a turned cross and lock onto the click) or **wavy** (four lines wriggle out from the tip, straighten, then shrink away). Each pop starts at the very tip of the pointer and is gone in about half a second. It can cover every click on the site, or only the clicks inside one part of a page.
## Before you build: one question
Look through this project first: its root layout, its pages and sections, and anything that already reacts to clicks (a custom cursor, ripple effects, click sounds). Then ask me this in one message and wait for my answer:
- **Where should it pop?** Suggest the 1–3 places in my code it fits best: the whole site (one `<ClickPop />` in my root layout, suggested) or one part of a page I name (a hero, a pricing card, a game area), and say what would get in its way there (an existing click effect). I can pick one or name another.
*Why: one pop on every click feels like part of the site, but it should never fight another click effect.*
Ask nothing else. If I say *skip*, use the best suggestion.
## Keep it as it is
The five pops (their shapes, distances, timing and easing), the pop starting at the exact pointer tip on the press, and the light build (no layer until the first click, a layer that never catches the pointer, each pop removing itself), are the design. Keep them exactly as in the source, with the default type (`burst`) and the default color. If something doesn't fit my project, tell me instead of changing it.
- Add only the component file and the one place I picked. Don't add packages, change other files, or restyle anything.
- Don't add the demo parts from the Impeccable website: the dotted demo card, the "Click anywhere" text, the five type pills, the drawn pointers that pop on their own in the Types boxes and the home page's TV.
## Fastest path
If this project has a `components.json` (shadcn), run `npx shadcn@latest add https://impeccable-ui.com/r/click-pop.json`.
If the command succeeds, only fix import paths to match this project and skip ahead. If it fails or there is no `components.json`, build it by hand as below.
## Build it
- Stack: React 18 or 19 with TypeScript. No other packages: each pop is a tiny SVG drawn by one `requestAnimationFrame` loop that runs only while a pop is on screen.
- JavaScript project? Name the file `click-pop.jsx` and remove the type annotations; nothing else changes.
- Create this file, in this project's usual place for components:
- `components/ui/click-pop.tsx`
- Keep these exports and their names: `ClickPop` (also the default export), `clickPop`, `ClickPopProps`, `ClickPopOptions` and `ClickPopType`.
- Keep `"use client"` at the top in Next.js App Router projects. In other setups it is harmless.
- Keep the tuning values at the top exactly as written: `BOX`, `MAX_LIVE`, `BURST`, `RING`, `PARTICLES`, `CROSSHAIR`, `WAVY` and the easing curves under them. They are the design and its timing.
- Keep the fallbacks: nothing is on the page until the first click, the layer never catches the pointer (`pointer-events: none`), so clicks, drags and text selection pass straight through, and each pop removes itself when it ends. With `prefers-reduced-motion: reduce` there are no pops at all. Only the main mouse button pops.
## Use it
```tsx
// app/layout.tsx: once, and every click on the site pops.
import { ClickPop } from "@/components/ui/click-pop";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<ClickPop />
</body>
</html>
);
}
```
- Without children it renders nothing of its own: put it anywhere inside `<body>`, once. Two of them would pop twice.
- To pop only inside one part of a page, wrap that part instead: `<ClickPop className="...">...</ClickPop>`. The wrapper is a plain `div`, so give it the classes the part needs.
- `clickPop(x, y, { type, color, size })` fires one pop from code at a point on the screen (`clientX`, `clientY`).
## How the pop works
Read this before you touch anything, so you know what the code does and why it must stay as it is.
1. **The listener.** `<ClickPop />` without children listens for every press on the page (`pointerdown`, in the capture phase and passive, so it never blocks or delays a click). With children, it listens only inside its wrapper. It pops on the press, not on release, so it feels instant.
2. **The layer.** On the first pop it adds one fixed, see-through layer over the page that never catches the pointer. Each pop is a small SVG in that layer, centred on the pointer tip. When the last pop ends, the layer is removed, so nothing stays on the page between clicks.
3. **The frame loop.** One `requestAnimationFrame` loop draws every pop on screen and stops as soon as none are left. Fast clicking keeps at most 12 pops at once; the oldest goes first.
4. **The types.** Burst: four lines at -58, -24, 14 and 48 degrees from straight up travel from 18px to 40px out, shrink to dots and fade after the halfway mark, in 0.42 seconds. Ring: opens from 3px to 26px while its line thins, in 0.52 seconds. Particles: eight dots, each a little off its slot and a little nearer or farther, drift down as they shrink, in 0.62 seconds. Crosshair: four ticks start as a cross turned 45 degrees, swing straight while they close from 20px to 9px, and a dot grows in the middle, in 0.48 seconds. Wavy: four lines (left, up-left, up and up-right) wriggle out to 56px, straighten as they arrive, then shrink toward their outer end, in 0.4 seconds.
5. **The color.** The color is set on each SVG and every line uses `currentColor`, so any CSS color works, including a theme variable that changes in dark mode.
## Check
- It type-checks and the page renders with no console errors.
- Every click in the place I picked pops at the very tip of the pointer: four short lines shoot out above it and fade in about 0.4 seconds. Links, buttons, drags and text selection still work exactly as before.
- It looks right in light and dark mode (check both): the violet reads on both.
- On a phone, a tap pops the same way and scrolling stays smooth.
- With `prefers-reduced-motion: reduce`, nothing pops.
- Nothing else on the site looks or behaves differently.
- Finish with a short report: the files you added or changed, where it's placed, and every place where you had to do something differently from the source, and why.
## Source
The reference implementation. Copy it as-is, then apply only the changes listed above.
### `components/ui/click-pop.tsx`
```tsx
"use client";
/**
* Click Pop, from Impeccable.
*
* A small pop of lines or dots at the pointer every time someone clicks.
* Five types:
* burst four short lines shoot out above the pointer tip, shrink to dots and fade
* ring a thin ring opens around the click and fades
* particles eight dots scatter all around, drift down a little and fade
* crosshair four ticks swing in from a turned cross and lock onto the click
* wavy four lines wriggle out from the tip, straighten, then shrink away
*
* Put <ClickPop /> once in your layout for the whole page, or wrap a part of
* the page in it so only clicks inside that part pop. You can also fire one
* from code with clickPop(x, y).
*
* Light on purpose: nothing is on the page until the first click. Each pop is
* one tiny SVG in a fixed layer that never catches the pointer, so clicks,
* drags and text selection pass straight through, and it removes itself when
* it ends. One animation frame loop runs only while a pop is on screen.
* Reduced motion gets no pops.
*
* No packages.
*/
import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";
export type ClickPopType = "burst" | "ring" | "particles" | "crosshair" | "wavy";
export type ClickPopOptions = {
/** Which pop. Default: "burst". */
type?: ClickPopType;
/** Any CSS color, including var(--brand) or currentColor. Default: a soft violet that reads on light and dark. */
color?: string;
/** 1 is the designed size. 0.7 is smaller, 1.3 bigger. Default: 1. */
size?: number;
};
export type ClickPopProps = ClickPopOptions & {
/** Pop on touch taps too. Default: true. */
touch?: boolean;
/** Wrap part of the page so only clicks inside it pop. Without children, every click on the page pops. */
children?: ReactNode;
/** On the wrapper, only when there are children. */
className?: string;
style?: CSSProperties;
};
/* ---------- the design: keep as written ---------- */
const DEFAULT_COLOR = "#8b74f6"; // soft violet, reads on light and dark
const BOX = 160; // px, the square each pop draws in, centred on the pointer tip
const MAX_LIVE = 12; // fast clicking never piles up more than this
// Burst: four rays above the tip (degrees from straight up, minus = left).
const BURST = { MS: 420, RAYS: [-58, -24, 14, 48], LENGTH: 11, FROM: 18, TO: 40, WIDTH: 2, HOLD: 0.55 };
// Ring: opens around the click.
const RING = { MS: 520, FROM: 3, TO: 26, WIDTH: 2, HOLD: 0.35 };
// Particles: dots all around, a little gravity.
const PARTICLES = { MS: 620, COUNT: 8, JITTER: 14, NEAR: 22, FAR: 40, DOT: 1.6, DOT_JITTER: 0.8, FALL: 8, HOLD: 0.45 };
// Crosshair: ticks swing in from 45 degrees and close on the click.
const CROSSHAIR = { MS: 480, TURN: 45, FROM: 20, TO: 9, LENGTH: 7, WIDTH: 2, DOT: 1.4, HOLD: 0.6 };
// Wavy: rays wriggle out, straighten, then shrink toward their outer end.
const WAVY = { MS: 400, RAYS: [-90, -42, 5, 51], OUT: 0.42, START: 14, REACH: 56, SHORT: 6, LONG: 20, WIDTH: 1.75, WAVE: 2.6, WAVELENGTH: 17, CALM: 0.48, HOLD: 0.8 };
/* ---------- easing ---------- */
/** The CSS cubic-bezier() curve as a function of time 0..1. */
function bezier(x1: number, y1: number, x2: number, y2: number) {
const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
const X = (t: number) => ((ax * t + bx) * t + cx) * t;
const Y = (t: number) => ((ay * t + by) * t + cy) * t;
const dX = (t: number) => (3 * ax * t + 2 * bx) * t + cx;
return (x: number) => {
if (x <= 0) return 0;
if (x >= 1) return 1;
let t = x;
for (let i = 0; i < 8; i++) {
const d = dX(t);
if (Math.abs(d) < 1e-6) break;
t = Math.min(1, Math.max(0, t - (X(t) - x) / d));
}
return Y(t);
};
}
const BURST_EASE = bezier(0.25, 0.5, 0.4, 1); // quick out, soft stop
const RING_EASE = bezier(0.2, 0.7, 0.3, 1);
const PARTICLE_EASE = bezier(0.15, 0.8, 0.3, 1); // pops fast, then drifts
const LOCK_EASE = bezier(0.2, 0.8, 0.2, 1);
const OUT_EASE = bezier(0.2, 0.7, 0.3, 1);
const IN_OUT_EASE = bezier(0.45, 0, 0.55, 1);
/** Holds at 1 until `hold`, then fades to 0 at the end. */
const fade = (t: number, hold: number) => (t < hold ? 1 : Math.max(0, 1 - (t - hold) / (1 - hold)));
/* ---------- drawing ---------- */
const NS = "http://www.w3.org/2000/svg";
type Draw = (t: number) => void;
function el<K extends "path" | "circle">(g: SVGGElement, tag: K) {
const e = document.createElementNS(NS, tag);
if (tag === "path") {
e.setAttribute("fill", "none");
e.setAttribute("stroke", "currentColor");
e.setAttribute("stroke-linecap", "round");
e.setAttribute("stroke-linejoin", "round");
} else {
e.setAttribute("fill", "currentColor");
}
g.appendChild(e);
return e as unknown as K extends "path" ? SVGPathElement : SVGCircleElement;
}
/** Direction of an angle given in degrees from straight up. */
const dir = (deg: number) => {
const a = (deg * Math.PI) / 180;
return [Math.sin(a), -Math.cos(a)] as const;
};
/** A straight stroke along a ray from `inner` to `outer`; a dot once it is shorter than its width. */
function ray(p: SVGPathElement, dx: number, dy: number, inner: number, outer: number, width: number) {
const cap = width / 2; // round caps add half a width at each end
const a = Math.min(inner + cap, (inner + outer) / 2);
const b = Math.max(outer - cap, a);
p.setAttribute("d", `M${(dx * a).toFixed(2)} ${(dy * a).toFixed(2)}L${(dx * b).toFixed(2)} ${(dy * b).toFixed(2)}`);
}
const MAKERS: Record<ClickPopType, { ms: number; make: (g: SVGGElement) => Draw }> = {
burst: {
ms: BURST.MS,
make(g) {
const rays = BURST.RAYS.map((deg) => ({ d: dir(deg), p: el(g, "path") }));
rays.forEach((r) => r.p.setAttribute("stroke-width", String(BURST.WIDTH)));
return (t) => {
const e = BURST_EASE(t);
const inner = BURST.FROM + (BURST.TO - BURST.FROM) * e;
const len = BURST.LENGTH * (1 - 0.85 * e);
const o = String(fade(e, BURST.HOLD));
for (const r of rays) {
ray(r.p, r.d[0], r.d[1], inner, inner + len, BURST.WIDTH);
r.p.setAttribute("opacity", o);
}
};
},
},
ring: {
ms: RING.MS,
make(g) {
const c = el(g, "circle");
c.setAttribute("fill", "none");
c.setAttribute("stroke", "currentColor");
return (t) => {
const e = RING_EASE(t);
c.setAttribute("r", (RING.FROM + (RING.TO - RING.FROM) * e).toFixed(2));
c.setAttribute("stroke-width", (RING.WIDTH * (1 - e) + 0.6).toFixed(2));
c.setAttribute("opacity", String(fade(e, RING.HOLD)));
};
},
},
particles: {
ms: PARTICLES.MS,
make(g) {
const turn = Math.random() * 360;
const dots = Array.from({ length: PARTICLES.COUNT }, (_, i) => {
const deg = turn + (360 / PARTICLES.COUNT) * i + (Math.random() * 2 - 1) * PARTICLES.JITTER;
return {
d: dir(deg),
far: PARTICLES.NEAR + Math.random() * (PARTICLES.FAR - PARTICLES.NEAR),
r: PARTICLES.DOT + Math.random() * PARTICLES.DOT_JITTER,
c: el(g, "circle"),
};
});
return (t) => {
const e = PARTICLE_EASE(t);
const o = String(fade(t, PARTICLES.HOLD));
const fall = PARTICLES.FALL * t * t;
for (const p of dots) {
p.c.setAttribute("cx", (p.d[0] * p.far * e).toFixed(2));
p.c.setAttribute("cy", (p.d[1] * p.far * e + fall).toFixed(2));
p.c.setAttribute("r", (p.r * (1 - 0.6 * t)).toFixed(2));
p.c.setAttribute("opacity", o);
}
};
},
},
crosshair: {
ms: CROSSHAIR.MS,
make(g) {
const ticks = [0, 90, 180, 270].map((deg) => {
const p = el(g, "path");
p.setAttribute("stroke-width", String(CROSSHAIR.WIDTH));
return { deg, p };
});
const dot = el(g, "circle");
return (t) => {
const e = LOCK_EASE(t);
const turn = CROSSHAIR.TURN * (1 - e);
const inner = CROSSHAIR.FROM + (CROSSHAIR.TO - CROSSHAIR.FROM) * e;
const len = CROSSHAIR.LENGTH * (1 - 0.3 * e);
const o = String(fade(t, CROSSHAIR.HOLD));
for (const k of ticks) {
const d = dir(k.deg + turn);
ray(k.p, d[0], d[1], inner, inner + len, CROSSHAIR.WIDTH);
k.p.setAttribute("opacity", o);
}
dot.setAttribute("r", (CROSSHAIR.DOT * e).toFixed(2));
dot.setAttribute("opacity", o);
};
},
},
wavy: {
ms: WAVY.MS,
make(g) {
const rays = WAVY.RAYS.map((deg, i) => {
const p = el(g, "path");
p.setAttribute("stroke-width", String(WAVY.WIDTH));
return { d: dir(deg), p, phase: i * 1.9 };
});
const STEPS = 14;
return (t) => {
let inner: number, outer: number;
if (t < WAVY.OUT) {
// Shooting out: the line grows as it travels.
const e = OUT_EASE(t / WAVY.OUT);
outer = WAVY.START + (WAVY.REACH - WAVY.START) * e;
inner = outer - (WAVY.SHORT + (WAVY.LONG - WAVY.SHORT) * e);
} else {
// Settled: the outer end stays, the inner end catches up until it is a dot.
const e = IN_OUT_EASE((t - WAVY.OUT) / (1 - WAVY.OUT));
outer = WAVY.REACH;
inner = WAVY.REACH - WAVY.LONG * (1 - e);
}
// The wriggle swells, then calms to a straight line before the shrink.
const wave = t < WAVY.CALM ? WAVY.WAVE * Math.sin((Math.PI * t) / WAVY.CALM) : 0;
const o = String(fade(t, WAVY.HOLD));
for (const r of rays) {
const [dx, dy] = r.d;
const len = outer - inner;
if (wave === 0 || len < WAVY.WIDTH * 2) {
ray(r.p, dx, dy, inner, outer, WAVY.WIDTH);
} else {
let d = "";
for (let s = 0; s <= STEPS; s++) {
const f = s / STEPS;
const along = inner + len * f;
// One wiggle every WAVELENGTH px, softer while the line is still short.
const side = wave * Math.min(1, len / 14) * Math.sin((2 * Math.PI * (len * f)) / WAVY.WAVELENGTH + r.phase - t * 18);
// perpendicular to the ray is (-dy, dx)
const x = dx * along - dy * side;
const y = dy * along + dx * side;
d += `${s ? "L" : "M"}${x.toFixed(2)} ${y.toFixed(2)}`;
}
r.p.setAttribute("d", d);
}
r.p.setAttribute("opacity", o);
}
};
},
},
};
/* ---------- the engine: one layer and one frame loop for every pop ---------- */
type Live = { node: SVGSVGElement; start: number; ms: number; draw: Draw };
const live: Live[] = [];
let layer: HTMLDivElement | null = null;
let frame = 0;
function tick(now: number) {
for (let i = live.length - 1; i >= 0; i--) {
const p = live[i];
const t = (now - p.start) / p.ms;
if (t >= 1) {
p.node.remove();
live.splice(i, 1);
} else {
p.draw(Math.max(0, t));
}
}
if (live.length) {
frame = requestAnimationFrame(tick);
} else {
frame = 0;
layer?.remove(); // nothing stays on the page between pops
layer = null;
}
}
/**
* Fire one pop at a point on the screen (clientX / clientY), from code.
* Does nothing on the server or with reduced motion.
*/
export function clickPop(x: number, y: number, options: ClickPopOptions = {}) {
if (typeof window === "undefined") return;
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const maker = MAKERS[options.type ?? "burst"] ?? MAKERS.burst;
const size = Math.max(0.2, options.size ?? 1) * BOX;
if (!layer) {
layer = document.createElement("div");
layer.setAttribute("aria-hidden", "true");
layer.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:2147483647;overflow:hidden;contain:strict";
document.body.appendChild(layer);
}
while (live.length >= MAX_LIVE) live.shift()?.node.remove();
const node = document.createElementNS(NS, "svg");
node.setAttribute("viewBox", `${-BOX / 2} ${-BOX / 2} ${BOX} ${BOX}`);
node.setAttribute("width", String(size));
node.setAttribute("height", String(size));
node.style.cssText = `position:absolute;left:${x - size / 2}px;top:${y - size / 2}px;overflow:visible;color:${options.color ?? DEFAULT_COLOR}`;
const g = document.createElementNS(NS, "g");
node.appendChild(g);
const draw = maker.make(g);
draw(0); // visible on the very frame of the click
layer.appendChild(node);
live.push({ node, start: performance.now(), ms: maker.ms, draw });
if (!frame) frame = requestAnimationFrame(tick);
}
/* ---------- the component ---------- */
export function ClickPop({ type = "burst", color, size, touch = true, children, className, style }: ClickPopProps) {
const wrap = useRef<HTMLDivElement>(null);
const opts = useRef({ type, color, size, touch });
opts.current = { type, color, size, touch };
const scoped = children !== undefined && children !== null;
useEffect(() => {
const host: HTMLElement | Window | null = scoped ? wrap.current : window;
if (!host) return;
const onDown = (e: Event) => {
const p = e as PointerEvent;
const o = opts.current;
if (p.button !== 0) return; // main button only
if (p.pointerType === "touch" && !o.touch) return;
clickPop(p.clientX, p.clientY, { type: o.type, color: o.color, size: o.size });
};
host.addEventListener("pointerdown", onDown, { capture: true, passive: true });
return () => host.removeEventListener("pointerdown", onDown, { capture: true });
}, [scoped]);
if (!scoped) return null;
return (
<div ref={wrap} data-click-pop="" className={className} style={style}>
{children}
</div>
);
}
export default ClickPop;
```
Usage
Put <ClickPop /> once in your layout and every click on the site pops. Wrap part of a page in it to keep the pops inside that part, or call clickPop() to fire one from code.
// app/layout.tsx: once, and every click on the site pops.
import { ClickPop } from "@/components/ui/click-pop";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<ClickPop type="burst" color="var(--primary)" />
</body>
</html>
);
}
// Or only inside one part of a page:
<ClickPop type="ring" className="rounded-2xl border p-8">
<Pricing />
</ClickPop>
// Or from code, at any point on the screen:
import { clickPop } from "@/components/ui/click-pop";
clickPop(event.clientX, event.clientY, { type: "particles" });How it moves
Every pop starts at the very tip of the pointer, on the frame of the press, and is gone in about half a second.
Burst throws four short lines up and out from just above the tip; they travel about 22px, shrink to dots and fade after the halfway mark, in 0.42 seconds. Ring opens from 3px to 26px around the click while its line thins out, in 0.52 seconds. Particles throws eight dots all around, each a little off its slot and a little farther or nearer, then lets them drift down as they shrink, in 0.62 seconds. Crosshair starts as a cross turned 45 degrees, swings straight as its four ticks close in on the click, and a dot appears in the middle, in 0.48 seconds. Wavy sends four lines out to the left and up, wriggling as they go; they straighten as they arrive, then shrink toward their outer end until they are dots, in 0.4 seconds. Nothing is on the page until the first click, the pops never catch the pointer, so clicks and text selection pass straight through, and each one removes itself when it ends. With reduced motion there are no pops.
Props
| Prop | Default | What it does |
|---|---|---|
type | "burst" | Which pop: "burst", "ring", "particles", "crosshair" or "wavy". |
color | soft violet | Any CSS color, like "var(--primary)" or "currentColor". It follows your theme when you pass a variable. |
size | 1 | 1 is the designed size. 0.7 is smaller, 1.3 bigger. |
touch | true | Pop on touch taps too. false keeps it to mouse and pen. |
children | — | Wrap part of a page and only clicks inside it pop. Without children, every click on the page pops. |
className / style | — | On the wrapper, only when there are children. |
clickPop(x, y, options) | — | Fires one pop from code at a point on the screen. Takes type, color and size. |