Display
Typewriter <pm-typewriter>
Typewriter: types a phrase, holds it, deletes it and types the next one, for the changing word in a headline.
Build apps that are
Overview
It is inline text: put it inside a heading or a sentence. Screen readers get all the phrases once, as plain text (or label), not letter by letter. It starts with the first phrase in full, waits while it is off screen, and with reduced motion (the system setting, or motion="none" / "reduced") it shows the first phrase and stays still. Between phrases only the letters that differ are retyped.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
words | string[] | [] | The phrases: words="fast|accessible|yours", a JSON array, or an array as a property. |
speed | number | 70 | Milliseconds per typed letter (default 70). |
delete-speedprop: deleteSpeed | number | 35 | Milliseconds per deleted letter (default 35). |
hold | number | 1800 | How long a finished phrase stays, in milliseconds (default 1800). |
once | boolean | false | Stop at the last phrase instead of starting over. |
paused | boolean | false | Stopped. Set it, or call stop() and play(). |
no-cursorprop: noCursor | boolean | false | Hide the cursor. |
label | string | — | Text for screen readers instead of the list of phrases. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-change | onPmChange | A phrase was typed in full. |
pm-finish | onPmFinish | With once: the last phrase was typed. |
CSS parts
| Part | Description |
|---|---|
::part(cursor) | The blinking cursor. |
Methods
stop(), play()