Text

Typography on the type scale, with semantic colors.

  • Composed
  • New in 0.1
import { Text, textPrimitive } from "nitro-ui-sdk/text";
HeroUI Native
TypographyText
Expo UI
Text
  • Text example screen, light appearance
    Light
  • Text example screen, dark appearance
    Dark
On this page

Text renders a string on the kit’s type scale (largeTitle to caption2) in a semantic color. It resolves its style once per variant and state and has no logic in render, so long lists of text stay cheap. heading marks a title for the VoiceOver headings rotor.

Use the parts of a family (Card.Title, ListGroup.Title) inside those families; use Text everywhere else.

Anatomy

import { Text } from "nitro-ui-sdk/text";

<Text>Route 12</Text>;
Part Description
root The native text, wrapped in a Semantics heading when heading is set.

Text.Root is the same component as Text.

Usage

import { Text } from "nitro-ui-sdk/text";

<Text>Twelve deliveries completed.</Text>;

Variants and sizes

variant is a step of the type scale: largeTitle, title1, title2, title3, headline, body (default), callout, subheadline, footnote, caption1, caption2. Each step sets font size, line height and weight from tokens.text.

color is any semantic color token: usually foreground (default), muted, accent, success, warning or danger. Colors follow the light and dark scheme.

import { Text } from "nitro-ui-sdk/text";

<Text variant="largeTitle" heading>
  Deliveries
</Text>;
<Text variant="footnote" color="muted" align="center" numberOfLines={2}>
  Updated just now
</Text>;
<Text variant="headline" color="danger" weight="bold">
  Two stops failed
</Text>;

States

Text has no interactive states. numberOfLines truncates with an ellipsis after that many lines.

Props

Text

Prop Type Default Description
variant TextVariant "body" Step of the type scale.
color keyof ColorTokens "foreground" Semantic color token.
weight "regular" | "medium" | "semibold" | "bold" the variant’s weight Overrides the weight.
align "start" | "center" | "end" | "justify" Text alignment.
numberOfLines number no limit Truncates after this many lines.
heading boolean false Marks the text as a heading for VoiceOver.
styles TextStyles Style resolver for root.
layout LayoutStyleProps Layout of the text.
children string | string[] The text.

Controller API

Text has no value or commands, so it has no controller.

Styles

import { Text, type TextStyles } from "nitro-ui-sdk/text";

const styles: TextStyles = {
  root: ({ tokens, variant, state }) => ({
    text: { color: variant === "caption2" ? tokens.colors.muted : tokens.colors[state.color], fontWeight: state.weight ?? "medium" },
  }),
};
<Text styles={styles}>Route 12</Text>;

The single part is root; the variant is the type step and the size is always md. Resolvers receive { tokens, variant, size, state } with state: { color; weight; align; numberOfLines }. resolveTextProps(tokens, variant, state) returns the default text props.

Accessibility

  • Plain text is read as static text.
  • heading wraps the text in a Semantics element with the heading trait and the full string as its label, so VoiceOver can jump between sections.
  • Sizes come from the type scale; keep body copy at body or larger.

Agent API

Read-only. Text adds no agent entry; the agent reads names from the controls that own them.

Platform notes

iOS Android
Text Composed over NitroUI Text (UILabel) and Semantics for headings; verified in the iOS harness. Same composition; written, compile-only on this machine.