Motion Kit

Text

Text Scramble

Scrambles characters on hover before settling back to the original text. Framework-agnostic Custom Element.

  • lit
  • gsap

Preview

Scrambles characters on hover before settling back to the original text.
Attributes

Installation

pnpm dlx shadcn@latest add https://motion-kit-astro.vercel.app/r/text-scramble.json

Usage

---
import "@/components/motion-kit/text-scramble-element.ts";
---

<motion-text-scramble text="Hello World"></motion-text-scramble>

API Reference

Attribute Type Default
text The text content to display and scramble. string ""
hover-target CSS selector for an external element that triggers the effect. Defaults to this element. string ""
scramble-duration Duration of the scramble animation in seconds. number 0.6
stagger Delay between each character's animation in seconds. number 0.03
cycles Number of random character cycles before settling. number 12
characters Character pool to use for scrambling effect. string "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*"