Bridge UI

Text

Body text with a semantic tone, color, size, and weight that follow light and dark mode.

Introduction

Text renders body copy with a semantic tone (default or muted), a color, a size, and a weight. Every color covers light and dark mode, so pages do not repeat text-dark-* dark:text-dark-* class pairs.

When to use: Paragraphs, captions, metadata, money and counts, and small uppercase labels.

Compared to similar components:

  • Heading — Section and page titles with a real h1–h6 element.
  • Label — Names a form control, with required and error states.

Use the framework selector in the site header to switch between React and Vue.

Import

import { Text } from "@bridge-ui/vue/Components/Text";
import { Text } from "@bridge-ui/react/Components/Text";

Basic usage

Text renders a p in the default tone. Use variant="muted" for subtitles, captions, and metadata.

Sizes

size goes from 2xs to 4xl and maps 1:1 to Tailwind text-*. The default is sm. Next to form controls, sm matches Label md.

Colors

color works with both variants: primary, secondary, success, info, warning, error, dark, and black. The default is dark. global.defaultColor does not apply to Text. Use inherit to keep the color of the parent.

Values, labels, and truncation

numeric aligns digits (tabular figures) for money and counts. uppercase makes a small label with wide tracking. truncate cuts the text to one line with an ellipsis. as changes the element, for example a span inside a sentence or an li in a list.

Defaults and tokens

Set app-wide defaults with components.Text.defaultProps (color, size, variant, weight). components.Text.tokens holds the classes for size, weight, and each variant and color, so the muted tone changes in one place. See Default props and Tokens.

defaultProps.size also sizes the text of components without a size prop: the title and body of Alert and Card, the title and description of Snackbar, the ColorPicker value, and the days, header, and times of the Calendar and TimePanel pickers. The Alert, Card, Snackbar, and ColorPicker parts render Text, so tokens and classes.root reach them too, but they keep the color and weight of their component. Components with a size prop (DataTable, FileUpload, form fields, …) size their text from their own size.

components: {
  Text: {
    defaultProps: { size: "xs" },
    tokens: {
      variant: {
        muted: { dark: "text-dark-600 dark:text-dark-300" },
      },
    },
  },
}

Accessibility

  • Text renders a p by default. Pick an element that matches the content with as (span inside a sentence, li in a list, dt / dd in a description list).
  • Use Heading for titles, not a large Text, so the page outline stays correct.
  • Color is not the only cue: pair success and error values with a sign or a word.

Anatomy

Text renders a single root element:

<p>…</p> <!-- root (element from `as`) -->

Heading, Card, Label

API

Prop Type Default Description
as "p" | "dd" | "dt" | "em" | "li" | "div" | "span" | "label" | "small" | "strong" | "figcaption" "p" Element rendered as the root.
children ReactNode — Text content (React). Vue uses the default slot.
classes TextClasses — Classes for root.
color TextColor "dark" Text color (inherit keeps the parent color). Ignores global.defaultColor.
numeric boolean false Tabular figures and tight tracking for money and counts.
size TextSize "sm" Font size, 2xs to 4xl, 1:1 with Tailwind text-*.
truncate boolean false Cuts the text to one line with an ellipsis.
uppercase boolean false Uppercase with wide tracking, for small labels.
variant TextVariant "default" Tone: default for main text, muted for secondary text.
weight TextWeight "normal" Font weight: normal, medium, semibold, or bold.