This app shows a text input where the user types their favorite color. The typed text appears below in real time.
import React, { useState } from 'react';
import { View, TextInput, Text, StyleSheet } from 'react-native';
export default function App() {
const [input, setInput] = useState('');
return (
<View style={styles.container}>
<Text style={styles.label}>Enter your favorite color:</Text>
<TextInput
style={styles.input}
value={input}
onChangeText={text => setInput(text)}
placeholder="Type color here"
accessibilityLabel="Favorite color input"
/>
<Text style={styles.output}>You typed: {input}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
padding: 20,
backgroundColor: '#fff'
},
label: {
fontSize: 18,
marginBottom: 10
},
input: {
borderWidth: 1,
borderColor: '#888',
padding: 10,
fontSize: 16,
borderRadius: 5
},
output: {
marginTop: 20,
fontSize: 18,
color: '#333'
}
});