data-text-effects
Declarative text effects using data attributes. Gradient, shimmer, glitch, reveal, blur-reveal, highlight, typewriter, and scramble effects that work on any text element.
data-gradient-text
CSS-only gradient coloring with theme-aware defaults and preset palettes. Add data-gradient-text-animate for a flowing animation.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-gradient-text | "", "sunset", "ocean", "forest", "neon" | Gradient preset. Empty uses theme primary→secondary. |
data-gradient-text-animate | boolean | Enable flowing gradient animation. |
data-shimmer
CSS-only shimmering highlight that sweeps across the text. A single bright hotspot slides through the text on a loop.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-shimmer | "", "slow", "fast" | Speed preset. Default is 2s cycle. |
data-glitch
Chromatic aberration glitch with cyan/red channel splitting via CSS pseudo-elements. Tiny JS sets a data-glitch-text attribute for the pseudo-element content.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-glitch | "", "hover" | Always-on or hover-triggered. |
data-reveal
Word-by-word or line-by-line entrance animation. Text slides up and fades in with staggered timing when scrolled into view.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-reveal | "", "word", "line" | Split mode. Default is word. |
data-reveal-delay | ms | Stagger delay between chunks (default 80). |
data-reveal-duration | ms | Animation duration per chunk (default 400). |
data-blur-reveal
Like data-reveal but words start blurred and transition to clear instead of sliding up. Creates a dreamy, focus-pull effect.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-blur-reveal | "", "word", "line" | Split mode. Default is word. |
data-blur-reveal-delay | ms | Stagger delay between chunks (default 80). |
data-highlight
Animated underline, box fill, or circle highlight that draws in when scrolled into view. Perfect for emphasizing key phrases.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-highlight | "", "underline", "box", "circle" | Highlight style. Default is underline. |
data-highlight-color | CSS color | Override color (default: currentColor). |
data-typewriter
Classic character-by-character typing with optional blinking cursor and looping. Triggers when scrolled into view.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-typewriter | ms per character | Typing speed. Default is 50ms. |
data-typewriter-delay | ms | Initial delay before typing starts (default 0). |
data-typewriter-cursor | "", "none" | Show or hide the blinking cursor. |
data-typewriter-loop | ms | Pause before looping. Omit for one-shot. |
data-scramble
Characters resolve left-to-right from random symbols. Think Hollywood decryption or sci-fi terminal output. Triggers on scroll.
Attributes
| Attribute | Values | Description |
|---|---|---|
data-scramble | ms | Total duration. Default is 1500ms. |
data-scramble-chars | string | Character set for random chars (default: !<>-_\\/[]{}=+*^?#). |
data-scramble-speed | ms | Frame interval. Default is 30ms. |
Shared Behavior
Progressive Enhancement
All effects are progressive enhancements. Text is fully readable without JavaScript. CSS-only effects (data-gradient-text, data-shimmer) need no JS at all.
Reduced Motion
All effects respect prefers-reduced-motion: reduce and :root[data-motion-reduced]. When reduced motion is active, text displays immediately with no animation.
Screen Readers
JS effects that split text into spans set aria-label on the host element so screen readers announce the full text naturally.
Scroll Trigger
JS effects use IntersectionObserver with threshold: 0.1 to trigger when scrolled into view. Effects play once (except data-typewriter with data-typewriter-loop).
Dynamic Elements
A MutationObserver watches for dynamically added elements, so effects work with client-side rendering and lazy loading.
Accessibility
aria-labelpreserves full text for screen readersprefers-reduced-motionrespected by all effects- CSS-only effects degrade gracefully in older browsers via
@supports - No content is hidden permanently — text is always accessible
- Guard attributes (
data-*-init) prevent double initialization