The Scramble
component displays text with the effect of βscatteredβ letters (hacker-text style). Suitable for dynamic headlines, downloads or accents.
bun add svelte-text-scramble
# or
npm install svelte-text-scramble
<script lang="ts">
import { Scramble } from 'svelte-text-scramble'
</script>
<Scramble value="Hello World!" />
Title | Type | Default | Description |
---|---|---|---|
value |
string |
β | Objective. The source text that will be βscatteredβ. |
duration |
number |
0.8 |
Animation duration (in seconds). |
characterSet |
string |
A-Z, a-z, 0-9 |
The set of symbols from which the βnoiseβ is generated. |
className |
string |
'' |
Custom CSS Classes. |
as |
keyof HTMLElementTagNameMap |
'p' |
HTML tag in which the text will be wrapped (p , span , div , etc.). |
trigger |
boolean |
true |
Automatically start animation when mounted or by condition set by `trigger |
onScrambleComplete |
() => void |
undefined |
Callback called after the animation is complete. |
...restProps |
HTMLAttributes<HTMLElement> |
β | Any valid HTML attributes (id , style , aria-* , etc.). |
<Scramble
value="Secret Code"
duration={1.5}
characterSet="β’ββββ
"
as="h2"
/>
trigger
<script lang="ts">
let active = false
</script>
<button on:click={() => (active = !active)}>Animate</button>
<Scramble value="Manual Trigger" trigger={active} />
<Scramble
value="Loaded!"
onScrambleComplete={() => console.log('ΠΠΎΡΠΎΠ²ΠΎ!')}
/>
MIT Β© 2025 @babxxh-dima