Scramble Text
paceui-gsap/scramble-textFreeComponent
A hover-triggered text effect that scrambles and restores characters with smooth motion
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/scramble-text.jsonSource
1"use client";23import { ComponentProps, useEffect, useRef } from "react";45import { useGSAP } from "@gsap/react";6import gsap from "gsap";7import { ScrambleTextPlugin } from "gsap/ScrambleTextPlugin";89gsap.registerPlugin(ScrambleTextPlugin);1011type ScrambleTextProps = {12 random?: boolean;13 scrambleOnLoad?: boolean;14} & ComponentProps<"div">;1516const defaultChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";1718export const ScrambleText = ({ scrambleOnLoad = true, random = true, ...props }: ScrambleTextProps) => {19 const wrapperRef = useRef<HTMLDivElement | null>(null);2021 const { contextSafe } = useGSAP();2223 const scramble = contextSafe(() => {24 const target = wrapperRef.current;25 if (gsap.isTweening(target) || !target) return;26 gsap.to(target, {27 duration: 1,28 ease: "sine.in",29 scrambleText: {30 text: target.innerText,31 speed: 2,32 chars: random ? defaultChars : target.innerText.replace(/\s/g, ""),33 },34 });35 });3637 useEffect(() => {38 if (scrambleOnLoad) scramble();39 const target = wrapperRef.current;40 target?.addEventListener("pointerenter", scramble);41 return () => target?.removeEventListener("pointerenter", scramble);42 }, [wrapperRef, scramble, scrambleOnLoad]);4344 return <div {...props} ref={wrapperRef} />;45};
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 |
