Text
Text is a view that displays one or more lines of read-only text. Use Text to display a string in your app's user interface. The Text view draws a string in a given font, with support for multiple lines, text truncation, and wrapping.
Text is a view that displays one or more lines of read-only text. Use Text to display a string in your app's user interface. The Text view draws a string in a given font, with support for multiple lines, text truncation, and wrapping.
Examples
Basic Usage
Preview unavailable for this example in the static docs build.
Show code
<Text>Hello, World!</Text>Long Text
Preview unavailable for this example in the static docs build.
Show code
<Text>This is a longer text that demonstrates how the Text component handles multiple lines of content. It will wrap naturally based on the container width.</Text>Line Limit
Preview unavailable for this example in the static docs build.
Show code
<Text lineLimit={2}>This is a very long text that will be truncated after the specified number of lines. The lineLimit prop controls how many lines are shown before truncation occurs.</Text>Single Line Limit
Preview unavailable for this example in the static docs build.
Show code
<Text lineLimit={1}>This text will be truncated to a single line with an ellipsis if it exceeds the container width.</Text>Custom Styling
Preview unavailable for this example in the static docs build.
Show code
<Text style={{
fontSize: '24px',
fontWeight: 'bold',
color: '#007AFF'
}}>Text with custom style</Text>Multiple Texts in VStack
Preview unavailable for this example in the static docs build.
Show code
<VStack spacing={10}>
<Text>First line</Text>
<Text>Second line</Text>
<Text>Third line</Text>
</VStack>Text in HStack
Preview unavailable for this example in the static docs build.
Show code
<HStack spacing={10}>
<Text>Left</Text>
<Text>Center</Text>
<Text>Right</Text>
</HStack>API
| Prop | Type | Required | Description |
|---|---|---|---|
lineLimit | number | No | The maximum number of lines to use for rendering text.
If nil, no line limit applies. Default: undefined (no limit) |
Inherits additional props from IBaseComponent.
Overview
Text is a view that displays one or more lines of read-only text. Use Text to display a string in your app's user interface. The Text view draws a string in a given font, with support for multiple lines, text truncation, and wrapping.
SwiftUI Correspondence: Similar to SwiftUI's Text.
Long Text
Text automatically wraps to multiple lines when needed:
Line Limit
Control the maximum number of lines displayed using the lineLimit prop:
Custom Styling
Apply custom styles to text:
Notes
- Text automatically wraps when it exceeds the container width
- Use
lineLimitto control text truncation - Text supports all standard CSS text styling properties
- Text can contain other React components as children
Best Practices
- Readability: Ensure sufficient contrast between text and background colors
- Line limits: Use
lineLimitappropriately to prevent layout issues with long text - Responsive: Text automatically adapts to container width
- Accessibility: Use semantic HTML and proper heading hierarchy
- Performance: Avoid excessive nested text components for better performance
TabView
TabView is a view that switches between multiple child views using interactive tabs. TabView provides a tabbed interface for organizing content into separate sections.
TextEditor
TextEditor is a native `<textarea>`-backed multiline editor for longer text such as comments, descriptions, and notes.