Motion Text

Storybook

A versatile, accessible text animation component with multiple animation modes, full accessibility support, and comprehensive customization options.

Preview

Usage

The Motion Text component provides beautiful text animations with zero configuration required. Simply pass text and let it animate automatically.

Animation Modes

The component supports six different animation modes:

  • gradient-in: Characters appear with a colorful gradient highlight reveal
  • fade-in: Smooth opacity-based character reveal
  • slide-in: Words slide up from below
  • gradient-sweep: Static text with an animated gradient sweep (loops automatically)
  • shimmer: Static text with an animated shimmer effect (loops automatically)
  • none: Instant text display without animation

Speed Control

Use t-shirt sizing (sm, md, lg) to control animation speed:

  • sm: Fast animation
  • md: Medium animation (default)
  • lg: Slow animation

Manual Control

Take full control of the animation lifecycle:

<template>
  <div>
    <dt-motion-text
      ref="textRef"
      text="Click to animate"
      :auto-start="false"
      @complete="onComplete"
    />

    <dt-button @click="$refs.textRef.start()">Start</dt-button>
    <dt-button @click="$refs.textRef.pause()">Pause</dt-button>
    <dt-button @click="$refs.textRef.resume()">Resume</dt-button>
    <dt-button @click="$refs.textRef.reset()">Reset</dt-button>
    <dt-button @click="$refs.textRef.skipToEnd()">Skip to End</dt-button>
  </div>
</template>

<script>
export default {
  methods: {
    onComplete() {
      console.log('Animation completed!');
    }
  }
}
</script>

Looping Animation

Perfect for attention-grabbing headers or hero sections:

Using Slots

You can also use the default slot instead of the text prop:

Vue API

Slots

Name
Description
default

Props

Name
Description
Default
animationMode

The animation mode to use for the text reveal.

Type: string
Values: gradient-infade-inslide-ingradient-sweepshimmernone
'gradient-in'
autoStart

Whether to start animation automatically when component is mounted.

Type: boolean
Values: truefalse
true
loop

Whether to loop the animation continuously.

Type: boolean
Values: truefalse
false
respectsReducedMotion

Whether to respect the user's prefers-reduced-motion system setting.

Type: boolean
Values: truefalse
true
screenReaderText

Alternative text for screen readers. If provided, this will be announced instead of the animated text.

Type: string
''
speed

Animation speed using t-shirt sizing.

Type: string
Values: smmdlg
'md'
text

The text content to animate.

Type: string
''

Events

Name
Description
complete

Emitted when the animation completes.

pause

Emitted when the animation is paused.

progress

Emitted during animation progress.

Type: { wordsComplete: number, totalWords: number, progress: number }
resume

Emitted when the animation resumes.

start

Emitted when the animation starts.

Accessibility

The Motion Text component is built with accessibility as a core principle.

Reduced Motion Support

Automatically respects the user's prefers-reduced-motion system setting. When enabled, animations are skipped and text appears instantly.

<dt-motion-text
  text="Respects user preferences"
  :respects-reduced-motion="true"
/>

Screen Reader Support

Provide alternative text for screen readers:

<dt-motion-text
  text="🎉 Congratulations!"
  screen-reader-text="Congratulations"
/>

ARIA Attributes

The component automatically includes proper ARIA attributes:

  • aria-live="polite" during animation
  • aria-label when screen reader text is provided
  • aria-hidden for animated content while animating

Best Practices

  1. Choose the right speed: Use sm for short text, lg for longer passages
  2. Don't overuse: Too many animated elements can be distracting
  3. Consider context: Hero sections work well with gradient-in, while body text might be better with fade-in
  4. Test with reduced motion: Always ensure your UI works with animations disabled
  5. Provide screen reader text: If using emojis or special characters, always include alternative text
Motion Text documentation last updated Thursday, June 11, 2026