import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
export default function StyledBox() {
return (
<View style={styles.box}>
<Text style={styles.text}>Hello Box</Text>
</View>
);
}
const styles = StyleSheet.create({
box: {
backgroundColor: 'blue',
padding: 20,
borderRadius: 10
},
text: {
color: 'white',
textAlign: 'center'
}
});We use StyleSheet.create to define a styles object that holds our style rules. This keeps styles organized and improves performance. The box style sets a blue background, padding around the content, and rounded corners. The text style makes the text white and centers it inside the box. We then apply these styles to the View and Text components using the style prop.