Let's think about this for a moment
StyleSheet.create() is a helper function that validates and optimizes style objects — using a plain object ({ }) directly still works, but StyleSheet.create gives you better performance and shows style-error warnings in development mode. Property names look similar to CSS but are camelCase (background-color → backgroundColor), and units aren't needed (no px — just plain numbers).
Let's connect this to a real scenario
If you want to combine multiple style objects on one component, you can use array syntax — style={[styles.base, styles.active]} applies base style first and then overrides with active style (the last item in the array has the highest priority). This array pattern makes it easy to implement conditional styling (e.g. a button's pressed state).
Code Example
import { StyleSheet, View, Text } from 'react-native';
const styles = StyleSheet.create({
card: {
backgroundColor: '#f0f0f0',
borderRadius: 12,
padding: 16,
marginBottom: 8,
},
title: {
fontSize: 18,
fontWeight: '600',
color: '#1a1a2e',
},
});
// Combining styles conditionally
<View style={[styles.card, isActive && styles.activeCard]}>
<Text style={styles.title}>Card Title</Text>
</View>You'll be able to style a card component with StyleSheet.create and combine conditional styles using array syntax.5-Minute Try-It
Write a card style yourself (backgroundColor, borderRadius, padding), then add a conditional style that changes the border color when isActive is true.
A Quick Heads-Up
Don't assume every style property matches CSS exactly — 'display: flex' is already the default for every View, but the default flexDirection is 'column' (unlike CSS on the web, where the default is 'row').