Split Text
Text reveals by word, character, or line, split from the real layout. Eight effects, no dependencies.
v0.2.0@magic-spells/split-text
$ npm i @magic-spells/split-textLive demo
Effect
<split-text effect="rise" split="chars">Pick an effect and replay it — the split and the reveal are the element’s own.
About
Lightweight text-reveal web component. Splits text into words, characters, or detected lines, then animates each unit with a CSS-driven stagger. Eight built-in effects — rise, drop, slide, bloom, two 3D spins, and a per-character magnetic scatter — plus a registry for writing your own. No dependencies. No framework. ~2.7 KB gzipped (JS) + 0.9 KB (CSS).
Features
- Three split modes: words, chars, lines (auto-detected from layout)
- Eight effects: rise (default), drop, slide-right, slide-left, bloom, spin-x, spin-y, magnetic
- Custom effects are just CSS — add a keyframe, get a new effect value
- CSS-only animation — transform, opacity, and filter, GPU-accelerated
- Triggers when scrolled into view by default (configurable: load, manual)
- Preserves inline markup (`, , , `) inside the host
Usage
<split-text>The quick brown fox jumps over the lazy dog.</split-text>
Attributes
| Attribute | Default | Description |
|---|---|---|
| split | words | words, chars, or lines |
| effect | rise | rise, drop, slide-right, slide-left, bloom, spin-x, spin-y, magnetic |
| delay | 0 | Initial delay before animation starts (ms) |
| stagger | 30 | Delay between each unit (ms) |
| duration | 800 | Animation duration per unit (ms) |
| easing | cubic-bezier(0.16, 1, 0.3, 1) | CSS easing function |
| trigger | visible | visible, load, or manual |
| offset | 20% | Distance above bottom of viewport before firing (px or %; set 0 to disable) |
About, features, usage and options are taken from the package README.