ThemedText
A text component that automatically applies theme-aware colors and includes predefined typography variants.Props
Typography variant to apply:
default: Regular body text (16px, line height 24)title: Large heading (32px, bold)defaultSemiBold: Semi-bold body text (16px, weight 600)subtitle: Section heading (20px, bold)link: Link styling (16px, blue color)
Override text color in light mode (e.g.,
"#000000")Override text color in dark mode (e.g.,
"#FFFFFF")Additional React Native style props
All standard React Native
Text props are supported (onPress, numberOfLines, etc.)Usage Examples
- Basic Usage
- Custom Colors
- With Custom Styles
- Real Example
Typography Variants
The component includes these predefined variants:| Variant | Font Size | Line Height | Weight | Use Case |
|---|---|---|---|---|
default | 16px | 24px | 400 | Body text |
defaultSemiBold | 16px | 24px | 600 | Emphasized text |
title | 32px | 32px | bold | Page titles |
subtitle | 20px | - | bold | Section headings |
link | 16px | 30px | - | Hyperlinks |
ThemedView
A view container that automatically applies theme-aware background colors.Props
Override background color in light mode (e.g.,
"#FFFFFF")Override background color in dark mode (e.g.,
"#000000")Additional React Native style props
All standard React Native
View props are supported (onLayout, testID, etc.)Usage Examples
- Basic Usage
- Custom Colors
- Real Example
Implementation Details
Both components use theuseThemeColor hook to automatically resolve colors:
components/themed-text.tsx
components/themed-view.tsx
Best Practices
Use themed components consistently
Use themed components consistently
Always use
ThemedText and ThemedView instead of the standard Text and View components to ensure your UI adapts properly to theme changes.Override colors sparingly
Override colors sparingly
Only use
lightColor and darkColor props when you need specific colors for branding or emphasis. Let the theme system handle most color decisions.Choose the right text variant
Choose the right text variant
Use appropriate text types for hierarchy:
title for page headers, subtitle for sections, defaultSemiBold for emphasis, and default for body text.Combine with layout styles
Combine with layout styles
Use the
style prop for layout and spacing (padding, margin, flexbox), while letting the component handle colors.Related
UI Components
Explore specialized components
Theming
Learn about the theming system