Text typed character by character, with an optional blinking cursor.
Installation
Usage
<script setup lang="ts">
import {
TypingText,
TypingTextCursor,
} from '@animate-ui/vue/primitives/texts/typing';
</script>
<template>
<TypingText :text="['Design', 'Build', 'Ship']" loop>
<TypingTextCursor />
</TypingText>
</template>Animation
- Characters are typed every
durationms (100). With several texts (orloop), a typed text holds forhold-delay, is erased at the same pace, and the next one is typed. - The text is written to the DOM directly: typing a character never re-renders Vue. Changing
durationorhold-delaymid-animation takes effect without restarting. - A loop pauses off screen and in a hidden tab; a single run only in a hidden tab. It resumes where it stopped.
- The cursor blinks (a 1s on/off loop) while it waits for
delayand once a text is typed, and stays solid while typing or erasing (it fades in over 0.3s as typing starts). It holds still off screen and in a hidden tab. - Under reduced motion, the text appears at once (the last text, or the first one with
loop) and the cursor doesn't blink. - Screen readers read every text once, never the partially typed ones.
API Reference
TypingText
| Prop | Type | Default |
|---|---|---|
text | string | string[] | - |
duration? | number | 100 |
delay? | number | 0 |
loop? | boolean | false |
hold-delay? | number | 1000 |
in-view? | boolean | false |
in-view-margin? | string | '0px' |
in-view-once? | boolean | true |
...props? | HTMLAttributes | - |
TypingTextCursor
| Prop | Type | Default |
|---|---|---|
variants? | Variants | - |
...props? | Omit<HTMLMotionProps<'span'>, 'children'> | - |