svelte-text-scramble Svelte Themes

Svelte Text Scramble

Animated text component for Svelte

πŸŒ€ Scramble β€” Animated text component for Svelte

The Scramble component displays text with the effect of β€œscattered” letters (hacker-text style). Suitable for dynamic headlines, downloads or accents.

πŸš€ Installation

bun add svelte-text-scramble
# or
npm install svelte-text-scramble

πŸ“¦ Utilization

<script lang="ts">
    import { Scramble } from 'svelte-text-scramble'
</script>

<Scramble value="Hello World!" />

πŸ”§ Props

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.).

🎯 Examples

Custom character set and duration

<Scramble
    value="Secret Code"
    duration={1.5}
    characterSet="β€’β—‰β—β—Žβ˜…"
    as="h2"
/>

Manual launch via trigger

<script lang="ts">
    let active = false
</script>

<button on:click={() => (active = !active)}>Animate</button>

<Scramble value="Manual Trigger" trigger={active} />

Callback after completion

<Scramble
    value="Loaded!"
    onScrambleComplete={() => console.log('Π“ΠΎΡ‚ΠΎΠ²ΠΎ!')}
/>

πŸ›  Technology

  • βœ… Svelte + TypeScript
  • 🎞 Animation based on Motion One
  • ⚑️ Lightweight, no unnecessary dependencies

πŸ“œ License

MIT Β© 2025 @babxxh-dima

Top categories

Loading Svelte Themes