Text
Text primitives with themes custom to each font
Text primitives connect semantic text, configured fonts, shared sizing, and Tamagui style props across web and native.
Features
Font-specific themes for spacing, weights, and sizes
Automatic theme matching through the size prop
Flat media, hover, press, and focus clauses
The base Text component is already included in @tamagui/core (and tamagui). This
package is optional and adds SizableText and Paragraph, which extend Text with the
size prop and theme-aware defaults.
Installation
If you’re using tamagui, SizableText and Paragraph are already included. Otherwise, install independently:
yarn
npm
bun
pnpm
Usage
Text
Text in Tamagui matches Text in react-native-web, with the added Tamagui props.
It explicitly does not inherit your theme color or other font properties, as it is meant to be plain and used for extension. Below, we show SizableText which extends Text, and Paragraph which extends SizableText. Generally, Paragraph is the useful component as it uses theme values, while you can extend Text if you want to derive your own design system.
SizableText
Tamagui lets you define font sizing, spacing, line height, letter spacing and other properties with createFont, of which you can have many different configurations. We’ve found a nice pattern is to “align” all your keys across these sub-objects.
SizableText adds a size property whose variant is a styled.dynamic callback, with a component resolver that looks for a matching key on each of these properties (using @tamagui/get-font-sized):
- color
- fontStyle
- textTransform
- fontFamily
- fontWeight
- letterSpacing
- fontSize
- lineHeight
So, if you’ve defined small, medium and large keys on each createFont category, you can use it like so:
Paragraph
Paragraph extends SizableText and is defined as:
Note: Paragraph renders to a p tag on web, which can cause issues when you nest them
during SSR. If you don’t mind rendering to a span, use SizableText, otherwise, be
careful when nesting items inside a Paragraph.
Inline text elements
For semantic inline text styling, @tamagui/text exports Strong, Em, and Span:
These render to their corresponding HTML elements (<strong>, <em>, <span>) on web while remaining compatible with React Native.
Text truncation
Tamagui provides two props for truncating text with ellipsis: ellipsis for single-line truncation and numberOfLines for multi-line clamping.
Single-line ellipsis
Use the ellipsis prop to truncate text to a single line with an ellipsis:
On web, this applies text-overflow: ellipsis, white-space: nowrap, and overflow: hidden. On native, it sets numberOfLines={1}.
Multi-line clamping
Use the numberOfLines prop to clamp text to a specific number of lines:
On web, multi-line clamping uses -webkit-line-clamp with -webkit-box display. On native, it passes numberOfLines directly to the React Native Text component.
The numberOfLines prop is supported on the base Text component from @tamagui/core
as well as SizableText and Paragraph. The ellipsis prop is a shorthand for
numberOfLines={1}.
API reference
Text
The base text component from @tamagui/core. Accepts all Tamagui style props for text elements.
Props
ellipsis
boolean
When true, truncates text to a single line with an ellipsis. Equivalent to numberOfLines={1}.
numberOfLines
number
Clamps text to the specified number of lines. Overflow is hidden. On web uses -webkit-line-clamp; on native uses the React Native numberOfLines prop.
SizableText
Extends Text with the size prop for theme-aware font sizing.
Props
size
SizeTokens | true
Sets font size, line height, letter spacing, and font weight from your theme's font configuration. Accepts any size token (e.g., "4") or true for the default size.
ellipsis
boolean
When true, truncates text to a single line with an ellipsis.
numberOfLines
number
Clamps text to the specified number of lines.
Paragraph
Extends SizableText with semantic defaults. Renders as <p> on web, uses theme color, and sets userSelect: 'auto' and whiteSpace: 'normal'.
Props
size
SizeTokens | true
Default:
trueSets font size from your theme. Defaults to the theme's base size.
ellipsis
boolean
When true, truncates text to a single line with an ellipsis.
numberOfLines
number
Clamps text to the specified number of lines.