The word inhales, spreading its letters and brightening, holds, then slowly exhales. A matching text-indent balances the trailing letter-spacing, so the word stays centered as it grows.
Also known as: breathe animation css, expanding letter spacing, calm text animation.
<div class="txt-breathing-text">Just breathe</div>
.txt-breathing-text {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
display: inline-block;
color: var(--c);
white-space: nowrap;
animation: txt-breathing-text-breathe 5s ease-in-out infinite;}
@keyframes txt-breathing-text-breathe {
0%, 100% { letter-spacing: 0; text-indent: 0; opacity: 0.55; }
42%, 55% { letter-spacing: 0.2em; text-indent: 0.2em; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.txt-breathing-text, .txt-breathing-text *, .txt-breathing-text::before, .txt-breathing-text::after, .txt-breathing-text *::before, .txt-breathing-text *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.