Adventureland Registry

Text Scramble

A GSAP ScrambleText-powered component that randomises characters into the final string, either on mount or on hover.

TextScramble wraps a <span> (optionally inside an <a>) and uses the GSAP ScrambleTextPlugin to animate characters from random noise into the final text. Set onHover to false (default) for a one-shot mount animation, or true to replay on every pointer enter and focus event. Respects prefers-reduced-motion.

Installation

npx shadcn@latest add @adv/text-scramble

Usage

import { TextScramble } from '@/components/ui/TextScramble';

{/* Auto-scrambles on mount */}
<TextScramble text="ADVENTURELAND" />

{/* Scrambles on hover */}
<TextScramble text="Hover over me" onHover className="cursor-pointer" />

{/* As a link */}
<TextScramble
  text="Open docs"
  href="https://example.com"
  target="_blank"
  onHover
/>

Example

Props

PropTypeDefaultDescription
textstringThe final text the scramble resolves to.
hrefstringWhen provided, the component renders an <a> tag instead of a <div>.
ariaLabelstringAccessible label for the link; falls back to text when omitted.
classNamestring"fluid"Class applied to the root element.
randomCharsbooleantrueUse random chars from charSet during scramble. When false, only chars from the target text are used.
durationnumber0.8GSAP tween duration in seconds.
speednumber2ScrambleText speed multiplier (higher = faster character resolution).
charSetstring"ABCDEFGHIJKLMNOPQRSTUVWXYZabcde..."Pool of characters used during scramble.
target"_blank" | "_self" | "_parent" | "_top""_blank"Link target attribute (only applies when href is set).
relstring"noopener noreferrer"Link rel attribute.
onHoverbooleanfalseWhen true, the animation replays on every pointerenter and focus event instead of only once on mount.
onComplete() => voidCallback fired when the scramble animation finishes.
upperCaseOnlybooleanfalseWhen true, strips lowercase letters from charSet (uppercase + digits only). When false, strips uppercase letters (lowercase + digits only).

On this page