Text Fall Button
paceui-gsap/text-fall-buttonFreeComponent
A button with dynamic text that falls into place with a smooth, elastic motion on hover or click.
Live preview
live · rendered by the registry
Rendered by PaceUI GSAP on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://gsap.paceui.com/r/text-fall-button.jsonSource
1"use client";23import { ComponentProps, MouseEvent, useEffect, useRef } from "react";45import { useGSAP } from "@gsap/react";6import gsap from "gsap";7import { SplitText } from "gsap/SplitText";89import { cn } from "@/lib/utils";1011gsap.registerPlugin(SplitText);1213type TextFallButtonProps = {14 effectOnHover?: boolean;15 effectOnLoad?: boolean;16} & ComponentProps<"button">;1718export const TextFallButton = ({19 className,20 children,21 effectOnHover = true,22 effectOnLoad = true,23 ...props24}: TextFallButtonProps) => {25 const buttonRef = useRef<HTMLButtonElement | null>(null);26 const textRef = useRef<HTMLSpanElement | null>(null);27 const splitTextRef = useRef<SplitText | null>(null);28 const timelineRef = useRef<gsap.core.Timeline | null>(null);2930 const { contextSafe } = useGSAP();3132 const triggerTextFallEffect = contextSafe(() => {33 const element = buttonRef.current;34 const splitText = splitTextRef.current;35 if (!element || !splitText) return;3637 timelineRef.current?.kill();3839 timelineRef.current = gsap.timeline();40 gsap.to(splitText.chars, {41 duration: 0,42 y: -60,43 });44 timelineRef.current45 .add("start")46 .to(element, {47 scale: 0.95,48 y: 4,49 duration: 0.1,50 })51 .to(element, {52 scale: 1,53 y: 0,54 duration: 0.2,55 })56 .to(57 splitText.chars,58 {59 duration: 1,60 y: 0,61 stagger: 0.05,62 ease: "elastic.out(0.75, 0.25)",63 },64 "start",65 );66 });6768 useEffect(() => {69 if (textRef.current)70 splitTextRef.current = new SplitText(textRef.current, {71 type: "chars",72 });73 if (effectOnLoad) {74 triggerTextFallEffect();75 }76 return () => {77 splitTextRef.current?.revert();78 splitTextRef.current = null;79 };80 }, [effectOnLoad, triggerTextFallEffect]);8182 const onClick = (e: MouseEvent<HTMLButtonElement>) => {83 triggerTextFallEffect();84 props.onClick?.(e);85 };8687 return (88 <button89 {...props}90 ref={buttonRef}91 onMouseEnter={() => effectOnHover && triggerTextFallEffect()}92 onClick={onClick}93// … truncated
What it pulls in
npm packages
Files it writes
More from PaceUI GSAP
All 29 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Modal Ability Selectorai-modal-ability-selector | PaceUI GSAP | Components | Free | 2 deps | |
| Modal Selectorai-modal-selector | PaceUI GSAP | Components | Free | 2 deps | |
| Response Writerai-response-writer | PaceUI GSAP | Components | Free | 2 deps · 2 files | |
| AI Suggestionsai-suggestions | PaceUI GSAP | Components | Free | 2 deps | |
| Modal Ability Selectorai-token-counter | PaceUI GSAP | Components | Free | 2 deps | |
| Animated Stackanimated-stack | PaceUI GSAP | Components | Free | 2 deps | |
| Bouncing Textbouncing-text | PaceUI GSAP | Components | Free | 2 deps | |
| Dot Flowdot-flow | PaceUI GSAP | Components | Free | 2 deps |
