color-flair-button
pixel-perfect/color-flair-buttonFreeBlock
A pill button with a directional color flair: stacked concentric circles bloom from
Install it
npx shadcn@latest add https://www.pixel-perfect.space/r/color-flair-button.jsonSource
1/**2 * A pill button with a directional color flair: stacked concentric circles bloom from3 * the cursor's entry point (GSAP staggered scale), trail it with per-circle lag, and4 * peel back inner→outer on exit.5 */6"use client";78import { useRef } from "react";9import { useGSAP } from "@gsap/react";10import gsap from "gsap";1112gsap.registerPlugin(useGSAP);1314const FLAIRS = [15 { color: "#A5A6F6", size: "210%" }, // purple16 { color: "#7BD88F", size: "158%" }, // green17 { color: "#FFD36E", size: "112%" }, // yellow18 { color: "#FF9BB3", size: "70%" }, // coral19];2021const ColorFlairButton = () => {22 const buttonRef = useRef<HTMLAnchorElement>(null);2324 useGSAP(25 () => {26 const button = buttonRef.current;27 if (!button) return;2829 const flairs = Array.from(30 button.querySelectorAll<HTMLElement>(".flair"),31 );3233 gsap.set(flairs, { xPercent: -50, yPercent: -50, scale: 0 });3435 const move = flairs.map((f, i) => {36 const duration = 0.65 - i * 0.12; // 0.65 → 0.29 across the stack37 return {38 x: gsap.quickTo(f, "x", { duration, ease: "power3" }),39 y: gsap.quickTo(f, "y", { duration, ease: "power3" }),40 xSet: gsap.quickSetter(f, "x", "px"),41 ySet: gsap.quickSetter(f, "y", "px"),42 };43 });4445 const getXY = (e: MouseEvent) => {46 const { left, top } = button.getBoundingClientRect();47 return { x: e.clientX - left, y: e.clientY - top };48 };4950 const onEnter = (e: MouseEvent) => {51 const { x, y } = getXY(e);52 move.forEach((m) => {53 m.xSet(x); // teleport every circle to the entry point...54 m.ySet(y);55 });56 gsap.to(flairs, {57 scale: 1,58 duration: 0.4,59 ease: "power3.out",60 stagger: 0.08,61 overwrite: "auto",62 });63 };6465 const onMove = (e: MouseEvent) => {66 const { x, y } = getXY(e);67 move.forEach((m) => {68 m.x(x);69 m.y(y);70 });71 };7273 const onLeave = (e: MouseEvent) => {74 const { x, y } = getXY(e);75 move.forEach((m) => {76 m.x(x);77 m.y(y);78 });79 gsap.to(flairs, {80 scale: 0,81 duration: 0.35,82 ease: "power3.out",83 stagger: { each: 0.07, from: "end" },84 overwrite: "auto",85 });86 };8788 button.addEventListener("mouseenter", onEnter);89 button.addEventListener("mousemove", onMove);90// … truncated
What it pulls in
npm packages
Files it writes
More from pixel-perfect
All 60 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3d-button3d-button | pixel-perfect | Blocks | Unverified | 2 deps | |
| abhinav-bento-buttonabhinav-bento-button | pixel-perfect | Blocks | Unverified | no deps | |
| accordion-carouselaccordion-carousel | pixel-perfect | Blocks | Free | 1 dep | |
| accordion-foldaccordion-fold | pixel-perfect | Blocks | Free | 1 dep | |
| activity-wheel-motionactivity-wheel-motion | pixel-perfect | Blocks | Free | 2 deps | |
| animated-textureanimated-texture | pixel-perfect | Blocks | Free | 1 dep | |
| aperture-mask-revealaperture-mask-reveal | pixel-perfect | Blocks | Free | 1 dep | |
| aurora-curtainaurora-curtain | pixel-perfect | Blocks | Free | no deps |
