Docs
Text
Scramble Hover

Scramble Hover

A text component that scrambles the text on hover.

Loading...

Installation


1pnpm dlx shadcn add @fancy/scramble-hover

Usage


For the scrambling effect, you can use either the original characters, or another set of characters specified in the characters prop.

Loading...

You can also apply a different styling on the scrambled text by passing a string to the scrambleClassName prop. This allows for example to use a different font family or color, like in the following example. Please not that if the scrambledClassName is applied, it's not going to be merged with the className prop, so you have to style the original text and the scrambled text separately.

Loading...

With the sequential prop, you can scramble the text in a sequential manner, starting from the start, the end, or the center of the text. In that case, the maxIterations prop is ignored. In my experience this works best with a monospaced font, but feel free to experiment.

Loading...

Props


PropTypeDefaultDescription

text*

string-The text to be displayed and scrambled
scrambleSpeednumber50Speed of the scrambling animation in milliseconds
maxIterationsnumber10

Maximum number of iterations for the scrambling animation

sequentialbooleanfalseWhether to scramble the text sequentially
revealDirection"start" | "end" | "center""start"The direction to reveal the scrambled text
useOriginalCharsOnlybooleantrue

Whether to use only the original characters or the whole string

classNamestringundefinedAdditional CSS classes for styling
charactersstring

"ABCDEFGHIJKLMNO PQRSTUVWXYZ abcdefghijklmno pqrstuvwxyz !@#$%^&*()_+"

Characters to use for scrambling, if useOriginalCharsOnly is false

scrambledClassNamestringundefined

Additional CSS classes for styling the scrambled text