# Typer Text

> Typing transition where words get staggered outline boxes while a solid accent cursor block sweeps across, scrambling characters before they settle.

<demo-typer-text>



</demo-typer-text>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/typer-text.json"
```

## Usage

```vue
<script setup lang="ts">
  import TyperText from '~/components/ui/typer-text/TyperText.vue';
</script>

<template>
  <TyperText
    text="design engineered by me :)"
    accent="#f97316"
    :speed="22"
    :cycles="4"
    :stagger="0.15"
    loop
  />
</template>
```

A solid accent block acts as the cursor: it lands on each character, cycles it
through random glyphs for `cycles` frames, then settles it and moves on. Words
are wrapped in dashed outline boxes that appear with a stagger and dissolve
once the whole line settles. Inherit font size/weight from the parent via
`class`.

## Props

<table>
<thead>
  <tr>
    <th>
      Prop
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        text
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      Text to type out
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        accent
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#f97316'
      </code>
    </td>
    
    <td>
      Cursor block + word outline color
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        speed
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        22
      </code>
    </td>
    
    <td>
      Reveal speed in frames per second
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cycles
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        4
      </code>
    </td>
    
    <td>
      Scramble cycles per character before settling
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        stagger
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.15
      </code>
    </td>
    
    <td>
      Seconds between word outline boxes appearing
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        autoplay
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Start typing on mount
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        loop
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Restart after a pause once finished
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hold-duration
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1800
      </code>
    </td>
    
    <td>
      Milliseconds to hold finished text before loop
    </td>
  </tr>
</tbody>
</table>

## Events

<table>
<thead>
  <tr>
    <th>
      Event
    </th>
    
    <th>
      Payload
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        done
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      Fired when the line settles
    </td>
  </tr>
</tbody>
</table>

## Credits

Ported from the "typer text transition effect" by
[@arlanoska](https://x.com/arlanoska/status/2074523602146488439)
([arlan.me/vault](http://arlan.me/vault)).
