In React Native, styling is done using JavaScript objects instead of traditional CSS files. Two common approaches are Inline Styles and External Styles (StyleSheet). Understanding when and how to use each approach helps in writing clean, reusable, and performant UI code.
style propStyleSheet.create() is used for external styles
// Inline styles written directly inside JSX
import { Text, View } from "react-native";
export default function App() {
return (
<View>
<Text style={{ color: "blue", fontSize: 20, marginTop: 20 }}>
Inline Styled Text
</Text>
</View>
);
}
// External styles using StyleSheet.create
import { Text, View, StyleSheet } from "react-native";
export default function App() {
return (
<View>
<Text style={styles.text}>
External Styled Text
</Text>
</View>
);
}
const styles = StyleSheet.create({
text: {
color: "green",
fontSize: 20,
marginTop: 20
}
});
Both examples render styled text on the screen. Inline styles apply styles directly, while external styles reuse predefined style objects. Visually, the result may look similar, but the structure and maintainability differ greatly.
Use the simulator below to understand how the code structure changes between Inline and External styling while the visual result remains the same.
StyleSheet.create() for performance