MOTION / 045

Typewriter reveal

文字を段階的に見せる
見える範囲を4段階で広げ、短い文字列を現します。

実際のHTML・CSSで描かれた見本です。

ラボで詳しく試す ↗

ひとつ試すなら

どこが変わるかを観察して、似た表現と見比べてみよう。

こんなときに

入力しているような雰囲気を、短いテキストに添えるとき。

仕組みと使い方

この見本は4段階のマスクです。文字幅が異なる書体では、一文字ずつには一致しません。

タイプライター一文字ずつ文字steps
実装コードを見る
<div class="demo">good</div>

<style>
.demo {
  display: inline-block; font: 900 64px/1.2 Arial, sans-serif; letter-spacing: -4px;
  color: #30323c;
  animation: typewriter 1600ms steps(4, end) infinite both;
}

@keyframes typewriter {
  0% { clip-path: inset(0 100% 0 0); }
  100% { clip-path: inset(0 0% 0 0); }
}
@media (prefers-reduced-motion: reduce) {
  .demo { animation: none; }
}
</style>