suiss/uim · React Native Component

Text

Styled text with typography variants for headings, body copy, quotes, code and captions.

Text is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Text on iOS in light mode

Text renders a React Native Text with one of twelve typography variants: default, h1–h4, p, blockquote, code, lead, large, small and muted. Heading variants also set the heading role.

It reads TextClassContext, so components such as Button can pass a text color and size down to any Text inside them.

Installation

$ pnpm dlx @esuiss/uim@latest add text

Manual

  1. Install the dependencies:
npx expo install class-variance-authority cn
  1. Add the pieces it builds on: the primitives components/primitives/types.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/text.tsx:

uniwind/components/ui/text.tsx
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import * as React from "react"
import { Text as RNText, type Role } from "react-native"
import type { RenderProp } from "@/components/primitives/types"
import { useRender } from "@/components/primitives/use-render"

const textVariants = cva("text-base text-label", {
  variants: {
    variant: {
      default: "",
      h1: "text-3xl font-bold",
      h2: "text-2xl font-bold",
      h3: "text-xl font-semibold",
      h4: "text-lg font-semibold",
      p: "mt-3",
  1. Update the import paths to match your project.

Usage

import { Text } from "@/components/ui/text"
<Text>The quick brown fox jumps over the lazy dog.</Text>

Pick a variant for the role of the text, and add classes through className for one-off changes.

Use the render prop to render a different component with the same classes. TextClassContext is exported so your own components can style nested Text the same way.

Examples

Typography

Every variant in a sample article.

iOS
Text (typography) on iOS in light mode

Headings

The four heading levels.

iOS
Text (headings) on iOS in light mode

API Reference

Text

The text element with typography variants.

ExtendsReact.ComponentProps<typeof RNText>React.RefAttributes<typeof RNText>TextVariantProps
PropType
About
Renders another component in place of the default Text, with the same props.
Type
RenderProp<Record<string, unknown>, Record<string, never>>
Default
—

Accessibility

  • h1 to h4 set role="heading", so VoiceOver and TalkBack can navigate by heading.
  • Text scales with the system font size.

Notes

  • Colors use the text-label and text-label-secondary tokens; code uses bg-surface-secondary and blockquote a border-separator start border.
  • Light and dark colors follow the system appearance.