Veil UI
Components

Text

A polymorphic text primitive with size, weight and tone presets.

Installation

$ npx veil-ui@latest add text

Usage

import { Text } from "@/components/ui/text";

<Text size="sm" tone="muted">
  Updated a moment ago
</Text>;

Examples

Basic

Ship a polished interface without a component wrapper library.

Tones and weights

Default body text

Muted supporting text

Destructive status text

Semibold emphasis

Truncate

A long single line that gets clipped with an ellipsis instead of wrapping onto the next line.

truncate keeps the text on one line and clips it with an ellipsis. For multi-line clamping use Truncated Text.

API reference

PropTypeDefaultDescription
as"p" | "span" | "div" | "label" | "strong" | "em""p"Element rendered by the primitive.
size"xs" | "sm" | "base" | "lg" | "xl""base"Font size preset.
weight"normal" | "medium" | "semibold" | "bold""normal"Font weight preset.
tone"default" | "muted" | "destructive""default"Foreground color tone.
truncatebooleanfalseClip a single line with an ellipsis.

Accessibility

  • Renders a real text element rather than a generic div, so semantics follow the chosen as value.
  • Avoid truncating the only copy of essential information; expose the full value through a title or details view when needed.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add text --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { cn } from "@/lib/utils";

import type { TextProps } from "./types";

const sizes = {
  xs: "text-xs",
  sm: "text-sm",
  base: "text-base",
  lg: "text-lg",
  xl: "text-xl",
} as const;

const weights = {
  normal: "font-normal",
  medium: "font-medium",
  semibold: "font-semibold",
  bold: "font-bold",
} as const;

const tones = {
  default: "",
  muted: "text-muted-foreground",
  destructive: "text-destructive",
} as const;

const props = withDefaults(defineProps<TextProps>(), {
  as: "p",
  size: "base",
  weight: "normal",
  tone: "default",
  truncate: false,
});
</script>

<template>
  <component
    :is="props.as"
    data-slot="text"
    :class="
      cn(
        sizes[props.size],
        weights[props.weight],
        tones[props.tone],
        props.truncate && 'truncate',
        props.class,
      )
    "
  >
    <slot />
  </component>
</template>

On this page