JSFiddle - React, Tailwind, and code Playground
by CBroe
HTML
<h1 data-text="Incoming Call" data-placeholder="........ ...." style="--text-length: 13;" data-text-length="13">Incoming Call</h1>
CSS
* { margin: 0; padding:0; box-sizing: border-box; }
html, body {
display: flex;
min-height: 100vh;
justify-content: center;
align-items: center;
color: #fff;
background: #111;
}
h1 {
position: relative;
font-family: monospace;
color: transparent;
border: .125em solid #fff;
border-radius: .25em;
padding: .125em .75em;
}
h1::before, h1::after {
position: absolute;
color: #fff;
top: .125em;
left: .75em;
}
h1::before {
content: attr(data-text);
clip-path: inset(0% 100% 0% 0%);
animation: .75s steps(14, jump-none) .75s forwards reveal;
}
h1::after {
content: attr(data-placeholder);
text-align: right;
clip-path: inset(0% 100% 0% 0%);
animation: .75s steps(14, jump-none) 0s forwards reveal, .75s steps(14, jump-none) .75s forwards repeal;
}
@keyframes reveal {
from {
/* top, right, bottom and left offsets */
clip-path: inset(0% 100% 0% 0%);
}
to {
clip-path: inset(0% 0% 0% 0%);
}
}
@keyframes repeal {
from {
/* top, right, bottom and left offsets */
clip-path: inset(0% 0% 0% 0%);
}
to {
clip-path: inset(0% 0% 0% 100%);
}
}