SwipeUI

Text

Text on the SwipeUI type scale, with headings announced to screen readers and a context that lets parents set label colours.

npx @swipeui/cli add text
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Every piece of text in your app, so sizes come from one type scale and follow your preset.
  • Screen titles and section headings that screen readers should treat as headings.
  • Labels inside custom buttons, where the parent sets the colour through TextClassContext.
  • Body copy, captions and footnotes that grow with the user's text size.

When not to use it

  • Numbers that animate. Use Animated counter or Slot text.
  • Text that should morph or reveal. Use Text morph or Text reveal.
  • Editable text. Use Text field.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add text
  • Adds components/swipeui/ui/text.tsx and 1 shared helper.
  • Installs class-variance-authority, clsx, tailwind-merge. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/settings.tsx
import { Text } from '@/components/swipeui/ui/text';

<Text variant="large-title">Settings</Text>
<Text variant="footnote" className="text-muted-foreground">Updated 2 minutes ago</Text>

variant picks a style from the type scale. The default colour is text-foreground; className overrides it.

Examples

scale names every type style in order; article composes a headline, byline and two paragraphs. No demo controls. The app and website share these boards.

API reference

PropTypeDefaultDescription
variant?TextVariant'body'

A style from the iOS type scale. Sizes follow the user's text size setting.

className?string—

Classes merged over the variant and any inherited classes.

Every React Native Text prop passes through.

Composition and behavior

  • variant picks a style from the iOS type scale: large-title, title-1 to title-3, headline, body, callout, subheadline, footnote, caption-1 and caption-2.
  • TextClassContext lets a parent pass classes to the Text inside it.
  • All other React Native Text props pass through.

Parent classes

TextClassContext lets a parent style the text inside it. Button uses it to colour its label:

components/primary-label.tsx
import { Text, TextClassContext } from '@/components/swipeui/ui/text';

<TextClassContext.Provider value="text-primary-foreground font-semibold">
  <Text>Inherits the parent's classes</Text>
</TextClassContext.Provider>;

The text's own className still wins.

Behavior and gestures

  • Static text; it doesn't respond to touch unless you wrap it in Pressable.
  • Sizes follow the user's text size setting automatically.

Accessibility

  • large-title and title-1 to title-3 are announced as headings, so people can jump between sections; pass accessibilityRole to change that.
  • Font scaling stays on, so text grows with Dynamic Type and Android font size.
  • Set maxFontSizeMultiplier only where a layout would genuinely break.
  • Colours come from your theme tokens, so contrast follows your preset.

Motion

  • Static on its own; any movement comes from the parent that animates it.
  • Static.

Performance

  • A thin wrapper over React Native Text with class merging.

Notes for AI

  • Use variant for size and role; don't hand-set font sizes.
  • Use TextClassContext in parents that colour their labels.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items