Skip to content

TextBox

The TextBox component renders styled text with colors, effects, and automatic wrapping. Use it as the primary text component in terminal UIs.

For static multicolor text, see the Gradient component in docs/components/text/gradient.md.

Basic Usage

vue
<template>
  <TextBox>Hello, World!</TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Props

NameTypeDefaultDescription
colorstring-Text color: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'gray'
bgstring-Background color (same options as color)
boldbooleanfalseMake text bold/bright
italicbooleanfalseMake text italic
underlinebooleanfalseUnderline text
dimbooleanfalseMake text dimmer
effectstring-Apply a text effect (rainbow, pulse, wave, shimmer)
effectPropsobject-Effect-specific options (see effects below)
animatedbooleanfalseEnable animation for animated effects
animationIntervalnumber-Override the effect's default frame interval (ms)

Layout Props (Box Props)

NameTypeDefaultDescription
flexnumber | stringnullFlex shorthand when inside a flex container
flexGrownumbernullFlex grow factor
flexShrinknumbernullFlex shrink factor
flexBasisnumber | stringnullFlex basis
alignSelfstringnullSelf alignment: 'auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline'
widthnumber | stringnullWidth (chars or %)
heightnumber | stringnullHeight (rows)
minWidthnumbernullMinimum width
maxWidthnumbernullMaximum width
minHeightnumbernullMinimum height
maxHeightnumbernullMaximum height
paddingnumbernullPadding
paddingLeftnumbernullLeft padding
paddingRightnumbernullRight padding
paddingTopnumbernullTop padding
paddingBottomnumbernullBottom padding
marginnumbernullMargin
marginLeftnumbernullLeft margin
marginRightnumbernullRight margin
marginTopnumbernullTop margin
marginBottomnumbernullBottom margin

Text Colors

Apply color to text:

vue
<template>
  <Col gap="1">
    <TextBox color="red">Red text</TextBox>
    <TextBox color="green">Green text</TextBox>
    <TextBox color="blue">Blue text</TextBox>
    <TextBox color="yellow">Yellow text</TextBox>
    <TextBox color="magenta">Magenta text</TextBox>
    <TextBox color="cyan">Cyan text</TextBox>
    <TextBox color="white">White text</TextBox>
    <TextBox color="gray">Gray text</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Background Colors

Apply background color:

vue
<template>
  <Col gap="1">
    <TextBox bg="red" color="white">Red background</TextBox>
    <TextBox bg="green" color="black">Green background</TextBox>
    <TextBox bg="blue" color="white">Blue background</TextBox>
    <TextBox bg="cyan" color="black">Cyan background</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Text Effects

Bold

vue
<template>
  <Col gap="1">
    <TextBox bold>Bold text</TextBox>
    <TextBox bold color="cyan">Bold cyan</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Italic

vue
<template>
  <Col gap="1">
    <TextBox italic>Italic text</TextBox>
    <TextBox italic color="green">Italic green</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Underline

vue
<template>
  <Col gap="1">
    <TextBox underline>Underlined text</TextBox>
    <TextBox underline color="blue">Underlined blue</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Dim

vue
<template>
  <Col gap="1">
    <TextBox dim>Dim text</TextBox>
    <TextBox dim color="cyan">Dim cyan</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Text Effects (Animated)

TextBox supports animated effects via the effect prop. When an effect is set, TextBox applies the effect instead of the base text styles (color, bold, italic, underline, dim). Padding and wrapping still apply.

Basic Usage

vue
<template>
  <TextBox
    effect="rainbow"
    :animated="true"
    :effectProps="{ speed: 1 }"
  >
    Animated rainbow text
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Available Effects

Rainbow

Animated rainbow gradient that scrolls across the text.

effectProps:

PropTypeDefaultDescription
speednumber1Animation speed multiplier
vue
<template>
  <TextBox effect="rainbow" :animated="true" :effectProps="{ speed: 2 }">
    Faster rainbow
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Pulse

Smooth brightness pulsing of a single color.

effectProps:

PropTypeDefaultDescription
colorstring'white'Base color to pulse
minBrightnessnumber0.4Minimum brightness (0 to 1)
maxBrightnessnumber1.0Maximum brightness (0 to 1)
vue
<template>
  <TextBox
    effect="pulse"
    :animated="true"
    :effectProps="{ color: '#00FFFF', minBrightness: 0.3, maxBrightness: 1.0 }"
  >
    Cyan pulse
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Wave

Animated color wave flowing across the text.

effectProps:

PropTypeDefaultDescription
colorsstring[]['#00FFFF', '#FF00FF']Gradient colors
wavelengthnumber10Wave length in characters
speednumber1Animation speed multiplier
vue
<template>
  <TextBox
    effect="wave"
    :animated="true"
    :effectProps="{ colors: ['#00FFFF', '#FF00FF'], wavelength: 8, speed: 1 }"
  >
    Color wave
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Shimmer

Animated highlight that sweeps across the text.

effectProps:

PropTypeDefaultDescription
baseColorstring'#666666'Base text color
highlightColorstring'#FFFFFF'Highlight color
widthnumber3Highlight width (characters)
speednumber1Animation speed multiplier
vue
<template>
  <TextBox
    effect="shimmer"
    :animated="true"
    :effectProps="{ baseColor: '#444444', highlightColor: '#FFFFFF', width: 5, speed: 1 }"
  >
    Shimmering text
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Animation Interval

Each animated effect has a default frame interval:

EffectDefault interval
rainbow100ms
pulse50ms
wave80ms
shimmer60ms

Override the interval per instance:

vue
<template>
  <TextBox
    effect="pulse"
    :animated="true"
    :animationInterval="120"
    :effectProps="{ color: '#FF6B35' }"
  >
    Slower pulse
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Combined Effects

Mix multiple effects together:

vue
<template>
  <Col gap="1">
    <TextBox bold color="cyan">Bright cyan</TextBox>
    <TextBox bold italic color="green">Bold italic green</TextBox>
    <TextBox bold underline color="yellow">Bold underlined yellow</TextBox>
    <TextBox bold color="white" bg="red">Bold white on red</TextBox>
    <TextBox dim color="gray">Dim gray</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Text Wrapping

TextBox automatically wraps text to fit the available width when used inside a container:

vue
<template>
  <Box border padding="1" width="40">
    <TextBox>
      This is a long text that will automatically wrap to fit within the box width. The TextBox component handles word wrapping intelligently.
    </TextBox>
  </Box>
</template>

<script setup>
import { Box, TextBox } from 'vuetty';
</script>

Force Specific Width

vue
<template>
  <TextBox width="30">
    This text will wrap at exactly 30 characters width regardless of container.
  </TextBox>
</template>

<script setup>
import { TextBox } from 'vuetty';
</script>

Common Patterns

Label and Value

vue
<template>
  <Row gap="2">
    <TextBox bold color="cyan">Status:</TextBox>
    <TextBox color="green">Active</TextBox>
  </Row>
</template>

<script setup>
import { Row, TextBox } from 'vuetty';
</script>

Section Header

vue
<template>
  <Col gap="1">
    <TextBox bold underline color="cyan">User Information</TextBox>
    <TextBox>Name: John Doe</TextBox>
    <TextBox>Email: john@example.com</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Status Indicator

vue
<template>
  <Row gap="1">
    <TextBox color="green" bold>✓</TextBox>
    <TextBox>Process completed successfully</TextBox>
  </Row>
</template>

<script setup>
import { Row, TextBox } from 'vuetty';
</script>

Highlighted Info

vue
<template>
  <Col gap="1">
    <TextBox bg="yellow" color="black" bold>Warning</TextBox>
    <TextBox>This action cannot be undone.</TextBox>
  </Col>
</template>

<script setup>
import { Col, TextBox } from 'vuetty';
</script>

Responsive Text

TextBox responds to terminal width changes automatically:

vue
<template>
  <Box border width="80" padding="1">
    <TextBox>
      This text will reflow when the terminal is resized. The TextBox component updates automatically to fit the new dimensions.
    </TextBox>
  </Box>
</template>

<script setup>
import { Box, TextBox } from 'vuetty';
</script>

Released under the MIT License.