Animation

Typewriter

Classic typewriter — types out a string char-by-char, optionally deletes it, then types the next string. Cycles through [texts] (or a single string) with a blinking cursor. Pure JS (no GSAP), pure CSS cursor blink.

Angular adaptation of an effect by David Haz / reactbits.dev.

Import

import { WrTypewriter } from 'ngwr/typewriter';

Playground

We design.
<wr-typewriter
  [texts]="['design.', 'ship.', 'iterate.']"
  [typingSpeed]="50"
  [deletingSpeed]="30"
  [pauseDuration]="2000"
  [loop]="true"
  cursorCharacter="|"
/>

Customize

Typing Speed (ms)
50 ms
Deleting Speed (ms)
30 ms
Pause (ms)
2000 ms
Loop
Cursor

API

NameDescriptionTypeDefault
textA single string to type. Use either text or texts — neither has a value on its own.string—
textsStrings to cycle. Use either text or texts — neither has a value on its own.readonly string[]—
typingSpeedPer-char typing speed in ms.number50
initialDelayDelay before typing starts, in ms.number0
pauseDurationPause after typing complete, before deleting, in ms.number2000
deletingSpeedPer-char deletion speed in ms.number30
loopLoop back to the first string after the last.booleantrue
showCursorShow the cursor glyph.booleantrue
hideCursorWhileTypingHide the cursor while typing / deleting.booleanfalse
cursorCharacterCursor glyph.string'|'
cursorBlinkDurationCursor blink half-cycle in seconds.number0.5
textColorsCycle through these colours per string.readonly string[][]
variableSpeedRandomise typing speed per char between min and max.{ min: number; max: number }—
reverseModeType each string backwards.booleanfalse
startOnVisibleStart only after the host enters the viewport.booleanfalse
(sentenceComplete)Emits { text, index } when a string finishes typing.{ text: string; index: number }—

CSS variables

Custom properties ngwr/typewriter publishes. Each default below is declared on the component's own selector, so a :root override is shadowed by it — set them on that selector, on a wrapper you scope yourself, or inline on the element. Unlike the BEM class names, these are the supported way to restyle the component.

VariableDefaultDeclared on
--wr-typewriter-cursor-blink0.5s.wr-typewriter