Text
Text is a foundational component for displaying text content with consistent styling.
Installation
Usage
Props
Text
Extends React Native's Text props.
Prop | Type | Default | Description |
---|---|---|---|
className | string | - | Additional Tailwind classes to apply. |
asChild | boolean | false | Use Slot component instead of RNText. |
Examples
Default Text
Custom Styling
Text Variants
With Background Context
Styling
The Text component uses Tailwind CSS classes for styling. Default styling includes:
- Base text size (
text-base
) - Default foreground color (
text-foreground
) - Selectable text on web (
web:select-text
) - Inherits font family from theme
- Supports all Tailwind typography classes
Common modifiers include:
- Font sizes:
text-sm
,text-base
,text-lg
,text-xl
- Font weights:
font-normal
,font-bold
- Font styles:
italic
,underline
- Colors:
text-primary
,text-secondary
, etc. - Line height adjustments
- Text alignment
- Text decoration
Context
The Text component uses a TextClassContext
that allows parent components to provide default text styling to all child Text components. This is useful for maintaining consistent typography within specific sections of your app.
Accessibility
The Text component:
- Uses semantic text structure
- Supports screen readers
- Maintains proper text contrast
- Ensures readable text sizes
- Allows text selection on web platforms
- Inherits accessibility properties from React Native's Text component