Typewriter
Text types itself with a blinking caret
How to use it
- Paste the HTML where the text animations should appear.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Typewriter · NedDev · eigen werk. -->
<div class="jouw-container">
<div class="twc-wrap" data-words="Wij bouwen.|Wij ontwerpen.|Wij leveren."><span class="twc-text"></span><span class="twc-caret"></span></div>
</div>/* Typewriter · NedDev · eigen werk. */
.twc-wrap{font:700 clamp(22px,5vw,46px)/1.1 'Boldonse','Switzer',sans-serif;color:#0a0a0a;display:flex;align-items:center;gap:.05em}
.twc-text{white-space:pre}.twc-caret{display:inline-block;width:.08em;height:1em;background:#F5480F;animation:twc-blink 1s steps(1) infinite}
@keyframes twc-blink{50%{opacity:0}}// Typewriter · NedDev · eigen werk.
// root = het element waarin de HTML staat
function init(root){
root=root.querySelector('.twc-wrap')||root;var out=root.querySelector('.twc-text');var words=(root.dataset.words||'Hello.').split('|');var reduce=matchMedia('(prefers-reduced-motion:reduce)').matches;if(reduce){out.textContent=words[0];return;}var wi=0,ci=0,del=false;function tick(){var w=words[wi];out.textContent=w.slice(0,ci);if(!del){ci++;if(ci>w.length){del=true;setTimeout(tick,1100);return;}}else{ci--;if(ci===0){del=false;wi=(wi+1)%words.length;}}setTimeout(tick,del?45:90);}tick();
}
init(document.querySelector('.jouw-container'));
More text animations
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →