Build: Box Styling Demo
This screen shows a colored box with margin, padding, and border to help understand spacing and borders in React Native.
Target UI
------------------------- | | | [ Colored Box ] | | | -------------------------
------------------------- | | | [ Colored Box ] | | | -------------------------
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function BoxStylingDemo() { return ( <View style={styles.container}> {/* TODO: Add the styled box here */} </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff', }, });
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function BoxStylingDemo() { return ( <View style={styles.container}> <View style={styles.box}> <Text>Hello Box</Text> </View> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff', }, box: { margin: 20, padding: 15, borderWidth: 3, borderColor: 'black', backgroundColor: 'red', }, });
We created a View styled as a box with margin, padding, border, and background color. Margin adds space outside the box, padding adds space inside around the text, and border draws a black line around the box. The text 'Hello Box' is inside the padded area.
------------------------- | | | ----------------- | | | Hello Box | | | ----------------- | | | -------------------------
padding do in a React Native style?View in React Native?margin: 10.View?
{
padding: 20,
margin: 10,
borderWidth: 5,
borderColor: 'red'
}{
margin: 15,
border: '2px solid black'
}View with a 15 pixel red border, 10 pixels padding inside, and 20 pixels margin outside. Which style object achieves this correctly?Pass the test and this pattern moves unknown