Basic Text Scramble
Loading...
Text Scramble on Hover
Loading...
Text Scramble with Custom Chars
Loading...
Usage Guide
Install the clsx and tailwind-merge packages:
npm install clsx tw-merge
Next, add cn utility function in your project:
import { twMerge } from "tailwind-merge";
import { clsx, type ClassValue } from "clsx";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
Copy and paste the following component source.
Props
Prop | Type | Description | Default |
---|---|---|---|
children | string | The text to display | "Hello, World!" |
duration | number | Duration of the scrambling animation (s). | 3 |
speed | number | The speed at which scrambling happens (ms). | 50 |
trigger | boolean | Trigger the animation. | true |
characterSet | string | Custom characters used for scrambling. | [A-Za-z0-9] |
className | string | Additional class names for styling. | _ |
as | string | HTML tag name to wrap the text inside | _ |
onScrambleEnd | function | Function to run after the scrambling ends | _ |