Split text
Zero learning curve. Up and running with one function.
Reveal text
Easily perform advanced text splitting techniques.
Target text
Pinpoint specific characters to create unique animations.
Revert text
Recompose text to its original state.
Like new features? Support splt's creator.
npm i spltjs
One import, no additional stylesheets required.
Works with plain CSS and Javascript libraries.
564B. Pretty much all there is to say about that.
Zero learning curve. Up and running with one function.
Easily perform advanced text splitting techniques.
Pinpoint specific characters to create unique animations.
Recompose text to its original state.
Various methods for getting up-and-running.
For production-quality projects.
npm i spltjs
For testing and small experiments.
<script src="https://www.unpkg.com/spltjs@1.1.0"></script>
A pre-fabricated sandbox for functionality testing.
Codepen template
To help with visualization, animations have been created with anime.js.
Text splitting will affect any HTML elements with the .splt class applied.
splt({});
anime({
targets: '.char',
translateY: [0, -20],
direction: 'alternate',
loop: 1,
delay: anime.stagger(25),
easing: 'cubicBezier(.71,-0.77,.43,1.67)'
});
we looked above
Edit splt’s default options to enable text reveals. Simply target the .reveal class to animate.
splt({
reveal: true
});
anime({
targets: '.reveal',
translateY: [0, 20],
direction: 'alternate',
loop: 1,
delay: anime.stagger(25),
easing: 'cubicBezier(.71,-0.77,.43,1.67)'
});
we saw stars
By default, splt allows you to target specific characters. The parent child relationship begins with instances, drills down further to characters, and once further to reveals if applicable.
splt({
reveal: true
});
anime({
targets: '#i1 #c1, #i1 #c2 #r',
translateY: [0, -20],
delay: anime.stagger(50),
easing: 'cubicBezier(.71,-0.77,.43,1.67)'
});
we ventured
Easily revert text back to its initial state.
anime({
begin: splt({}),
targets: '.char',
opacity: [0,1],
scale: [1, 1.5],
delay: anime.stagger(50),
easing: 'cubicBezier(.71,-0.77,.43,1.67)',
complete: () => {
splt.revert();
},
});
and grew lost
A dictionary of sorts.
reveal
boolean
false
target
string
'.splt'
splt.revert() Reverts text to its original state.
.splt The initial target selector.
.char The class applied to each individual character in a splt selection.
.reveal If the reveal option is true, this class is added to each character.
#i1 The id applied to each instance of a splt selection, also known as the parent element. The numeric value increases per instance to keep each unique and individually animatable.
#c1 The id applied to each character of an instance, also known as the child element. The numeric value increases per character.
#r If the reveal option is true, this id is applied to each character, it is also known as the grandchild element.