AnimationUpdated in v15

Typewriter

Types and deletes strings with a blinking cursor.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrTypewriter } from 'ngwr/bits/typewriter';

@Component({ imports: [WrTypewriter] })
export class MyComponent {}
Angular adaptation of an effect by David Haz / reactbits.dev.

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. Set this or texts.string—
textsStrings to cycle. Set this or text.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

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/bits/typewriter's own element.

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

See also