Skip to content

TypewriterText Typewriter Text

Neobrutalist-style typewriter effect text component that displays text character by character with a blinking cursor animation. Suitable for landing pages, welcome messages, code demonstrations, and similar scenarios.

Demo

Preview

基础用法

循环播放

尺寸与粗细

无光标

Installation

pnpm dlx brutx-vue@latest add typewriter-text

Usage

vue
<script setup>
import { TypewriterText } from 'brutx-ui-vue'
</script>

<template>
    <TypewriterText
        text="Welcome to BrutxUI!"
        :speed="80"
        cursor
    />
</template>

Loop Playback

vue
<template>
    <TypewriterText
        text="Continuous typing effect..."
        :speed="60"
        :delay="2000"
        loop
        cursor
    />
</template>

Event Listening

vue
<script setup>
import { TypewriterText } from 'brutx-ui-vue'

function onStart() {
    console.log('Typing started')
}

function onComplete() {
    console.log('Typing completed')
}
</script>

<template>
    <TypewriterText
        text="Callback triggered after typing completes"
        :speed="80"
        @start="onStart"
        @complete="onComplete"
    />
</template>

Variants

VariantCSS Class
normalfont-normal
mediumfont-medium
boldfont-bold
blackfont-black

Sizes

SizeCSS ClassCursor Height
smtext-smh-3
defaulttext-baseh-4
lgtext-lgh-5
xltext-xlh-6
2xltext-2xlh-7
vue
<template>
    <TypewriterText
        text="Large bold text"
        size="xl"
        weight="bold"
        :speed="100"
    />
</template>

Props

PropTypeDefaultDescription
textstring— (required)Text to display
speednumber50Typing speed (ms per character)
delaynumber0Delay time before typing starts (ms). In loop mode, also used as the interval between each restart
loopbooleanfalseWhether to loop playback
cursorbooleantrueWhether to show the cursor. The cursor is only visible during typing; in non-loop mode, it automatically hides after typing completes
size'sm' | 'default' | 'lg' | 'xl' | '2xl''default'Text size
weight'normal' | 'medium' | 'bold' | 'black''normal'Text weight
classstringCustom class name

Events

EventPayloadDescription
startTriggered when typing starts
completeTriggered when typing completes

Accessibility

  • ARIA attributes: The component uses aria-live="polite" to ensure screen readers can detect text changes; the cursor uses aria-hidden="true" to mark it as a decorative element
  • Motion reduction: When the user prefers prefers-reduced-motion: reduce, the full text is displayed immediately, skipping the animation; this preference responds to system setting changes in real time

FAQ

Q: What happens when the text prop changes?

A: When the text prop changes, the typing animation restarts.

Q: How are timers handled when the component is unmounted?

A: All timers (including typing timers and delay start timers) are automatically cleaned up when the component is unmounted to avoid memory leaks.

Q: What is the behavior in loop mode?

A: In loop mode, after typing completes, it waits for delay milliseconds before restarting.

Q: How do I customize styles?

A: The component root element always has the brutx-typewriter CSS class, which can be used for custom style overrides.

Brute force builds.