Text
The base text component, carrying the theme's type styles. The default body size differs by platform.
partially-compliant
- Overview
- Props
- Figma
Usage​
Use Text component to display text with theme styles. Default body size by platform: mobile $text300, desktop (e.g. customer dashboard) $text200. See Typography — Default body size. Control Text styles with props:
I'm a text in size 200 on web and 300 on mobile 👋
Weight, size, color, align, italic​
Use the color prop only when it carries a semantic meaning (e.g. links, errors, status). For normal text and headings, prefer neutral (grey) and express hierarchy with size and weight. See Color and text in the foundations.
Size 100 text
Size 200 text (default on web)
Size 300 text (default on mobile)
Size 400 text
Size 500 text
Medium
Bold
Italic
Indigo 500 text
Red 500 text
Aligned to center
Aligned to right
Responsive size​
size also accepts one size per breakpoint, like Heading. Widths that no key matches keep the default or inherited size. Paragraph, Strike and List accept it too.
Resize the window
Styling​
You can add additional styles through the sx prop:
Underline and uppercase
Number of lines & ellipsis​
You can truncate the text and add ellipsis by specifying the maximum number of line you need.
On web, adding this props will automatically change the display to block. You can have display issues.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Accessibility​
On the web, you should always wrap text content in a meaningful semantic element like <p>, <a>, <h1>, etc.
To help you do so Text will automatically set the tag to p if ancestors tags are decorative only, span otherwise.
Note: It works only with components based on our universal TypographyBase component.
Playground​
Migrating from TextDeprecated​
Before
After
size prop mapping​
| Old Value | New Value |
|---|---|
| size12 | $text100 |
| size14 | $text200 |
| size16 | $text300 |
| size18 | $text400 |
| size24 | $text500 |
murray and murray/mobile.Text props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| align | 9 possibilities"unset""left""right""end""start""auto""center""justify"undefined | |||
| aria-disabled | booleanundefined | |||
| aria-label | stringundefined | |||
| aria-level | numberundefined | Heading level when paired with `role="heading"`. | ||
| asChild | 5 possibilitiesboolean"web""except-style""except-style-web"undefined | |||
| className | stringundefined | |||
| color | 4 possibilitiesundefined`$${string}`Variable<any>OpaqueColorValue | Color prop accepts Tamagui color tokens, ColorTokens, or dynamic token strings. Examples: "$grey900", "$indigo500", "$white", or dynamically constructed tokens like `$${name}900` | ||
| dir | "auto"Directionundefined | |||
| ellipsizeMode | "head""middle""tail""clip"undefined | |||
| fontFamily | FontTokensundefined | |||
| htmlFor | stringundefined | |||
| id | stringundefined | |||
| italic | booleanundefined | |||
| lang | LocaleOrLanguageundefined | |||
| maxFontSizeMultiplier | numbernullundefined | |||
| numberOfLines | numberundefined | |||
| onLayout | ((e: LayoutChangeEvent) => void)undefined | |||
| onTextLayout | 2 possibilitiesundefined(e: NativeSyntheticEvent<TextLayoutEventData>) => void | Fires on mobile with the list of rendered lines. Passes through to the underlying RN Text. | ||
| role | Roleundefined | |||
| size | 9 possibilitiesundefinednumberVariable<any>"$text100""$text200""$text300""$text400""$text500"Partial<Record<"$xs" | "$ltVs" | "$vs" | "$ltSm" | "$sm" | "$ltMd" | "$md" | "$ltLg" | "$lg" | "$ltXl" | "$xl" | "$ltXxl" | "$xxl", TextSize>> | Font size and line height token, see `TypographyBaseProps["size"]`. Also accepts one size per breakpoint, e.g. `{ $xs: "$text200", $lg: "$text300" }`: widths that no key matches keep the default or inherited size. | ||
| sx | 2 possibilitiesundefinedOmit<TextProps, "fontStyle" | "fontFamily" | "fontWeight"> | |||
| tabIndex | stringnumberundefined | |||
| tag | "p""span"undefined | |||
| transform | 6 possibilities"none""capitalize""uppercase""lowercase""unset"undefined | |||
| weight | TextWeightundefined |
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| aria-hidden | any | |||
| aria-live | any | |||
| css | any | |||
| dangerouslySetInnerHTML | any | |||
| data-status | any | |||
| data-testid | any | |||
| title | any |
Style API​
Use sx for one-off adjustments. It accepts these style keys:
Each can be overridden per breakpoint with: