Glyphs flicker, then settle into the real phrase. Trigger it with a button or bump play from your own state.
Token ready
1100ms
28ms
tsx
"use client"import { useState } from "react"import { Scramble } from "@/components/motion/scramble"import { Button } from "@/components/ui/button"const TEXTS = [ "Token ready", "Copy and ship", "Compose freely", "Ship quieter UI"]export function Example() { const [index, setIndex] = useState(0) const [play, setPlay] = useState(0) return ( <div className="flex flex-col items-center gap-6"> <Scramble text={TEXTS[index]} play={play} duration={1100} speed={28} className="text-2xl font-medium tracking-wide text-foreground sm:text-3xl" /> <Button variant="outline" onClick={() => { setIndex((current) => (current + 1) % TEXTS.length) setPlay((current) => current + 1) }} > Scramble </Button> </div> )}Installation
npx @arctis-sh/@arctis-sh/ui@latest add scrambleUsage
import { useState } from "react"import { Scramble } from "@/components/motion/scramble"import { Button } from "@/components/ui/button"const [play, setPlay] = useState(0)<> <Scramble text="Token ready" play={play} /> <Button onClick={() => setPlay((n) => n + 1)}>Scramble</Button></>API Reference
Scramble
| Prop | Type | Default |
|---|---|---|
| text | string | — |
| play | number | 0 |
| duration | number | 1100 |
| speed | number | 28 |
| characters | string | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 |
| className | string | — |
Also accepts the other native span attributes. Duration and speed are in milliseconds.