Skip to main content

Text

Text is a typography element that displays content with theme type styles, such as screen titles, body copy, or captions.

Import

import { Text } from '@vortexlabs/vortex-native';
import type { TextProps } from '@vortexlabs/vortex-native';

Other links

<Text size="body-lg" weight="regular" color="default">Text content</Text>

Features

  • Applies heading, body, and link typography tokens.
  • Follows the system text size up to the theme's limit.
  • Limits text to a set number of lines with lineClamp.
  • Supports weight overrides, strikethrough, and tabular numbers.
  • Inherits size and color in nested Text.

Sizes

size applies a heading, body, or link type style. The default is body-md.

<Text size="heading-2xl">heading-2xl</Text>
<Text size="heading-xl">heading-xl</Text>
<Text size="heading-lg">heading-lg</Text>
<Text size="heading-md">heading-md</Text>
<Text size="heading-sm">heading-sm</Text>
<Text size="heading-xs">heading-xs</Text>
<Text size="body-xl">body-xl</Text>
<Text size="body-lg">body-lg</Text>
<Text size="body-md">body-md</Text>
<Text size="body-sm">body-sm</Text>
<Text size="body-xs">body-xs</Text>
<Text size="link-lg">link-lg</Text>
<Text size="link-md">link-md</Text>
<Text size="link-sm">link-sm</Text>

Weight

weight overrides the font weight of the size.

<Text weight="light">light</Text>
<Text weight="regular">regular</Text>
<Text weight="medium">medium</Text>
<Text weight="semibold">semibold</Text>
<Text weight="bold">bold</Text>
<Text weight="heavy">heavy</Text>
<Text weight="black">black</Text>

Color

color applies a semantic foreground color. The default is default.

<Text color="default">default</Text>
<Text color="subtle">subtle</Text>
<Text color="primary">primary</Text>
<Text color="critical">critical</Text>
<Text color="warning">warning</Text>
<Text color="success">success</Text>
<Text color="info">info</Text>

Alignment

align sets the text alignment; start and end follow the layout direction. Without it, Text uses the parent Stack's textAlign.

<Text align="start">start</Text>
<Text align="center">center</Text>
<Text align="end">end</Text>

Line Clamp

lineClamp sets the maximum number of visible lines. Overflowing text ends in an ellipsis.

<Text lineClamp={1}>
  Vortex text wraps by default and follows the system text size up to the theme's cap. A line limit ends in an ellipsis.
</Text>
<Text lineClamp={2}>
  Vortex text wraps by default and follows the system text size up to the theme's cap. A line limit ends in an ellipsis.
</Text>

Decoration

Set decoration to line-through for content such as a previous price.

<Text decoration="line-through">$120.00</Text>

Tabular Numbers

tabularNums gives every digit the same width, so numbers line up in columns.

<Text tabularNums>111.11</Text>
<Text tabularNums>888.88</Text>

Nested Text

Nested Text inherits the parent's size and color when they aren't set, so you can style part of a sentence.

<Text size="heading-md">
  Heading with{" "}
  <Text color="primary" weight="bold">
    nested
  </Text>{" "}
  text
</Text>

Accessibility

Description
Text renders a React Native Text and adds no role. Pass role, such as heading, through attributes when the content needs one.
Text scales with the system text size up to the theme's maxFontSizeMultiplier.
Avoid using lineClamp for content that must always be available to users.