Introduction
The Text component shows words or sentences on the screen. It helps users read information in your app.
The Text component shows words or sentences on the screen. It helps users read information in your app.
import { Text } from 'react-native'; export default function App() { return ( <Text>Some text here</Text> ); }
<Text>Hello World</Text>
<Text style={{color: 'blue', fontSize: 20}}>Blue Text</Text><Text>{`Count: ${count}`}</Text>This app shows two pieces of text centered on the screen. The first is a bold title, and the second is a smaller description.
import React from 'react'; import { SafeAreaView, Text, StyleSheet } from 'react-native'; export default function App() { return ( <SafeAreaView style={styles.container}> <Text style={styles.title}>Welcome to My App</Text> <Text style={styles.description}>This is a simple text example.</Text> </SafeAreaView> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#f0f0f0' }, title: { fontSize: 24, fontWeight: 'bold', marginBottom: 10 }, description: { fontSize: 16, color: '#333' } });
Always wrap Text components inside a container like View or SafeAreaView for layout control.
Use the style prop to make text readable and visually appealing.
Text components can contain nested Text components for mixed styles.
The Text component displays readable text in your app.
Use style to change how text looks.
Text can show static or dynamic content.
Text component in React Native?Text component in React Native?style={{key: value}} with double curly braces for inline styles.const name = 'Anna';
return <Text>Hello, {name}!</Text>name is 'Anna', so it replaces {name} with 'Anna'.return <Text style={{fontSize: 18, color: 'blue'}}>Welcome</Text>;Text component. Which code correctly shows "Good morning" if before noon, otherwise "Good afternoon"?Pass the test and this pattern moves unknown