React Native uses Flexbox, implemented by Yoga, and the properties are the ones you know. Three defaults differ from the web, and almost every layout surprise traces back to one of them.
First, flexDirection defaults to column, not row. Phones are tall, so stacking is the common case. Second, alignItems defaults to stretch, so children fill the cross axis unless told otherwise. Third, every View is display: flex and position: relative already - there is no need to declare it and no display: block to fall back to.
There are no units. A number is a density-independent pixel, scaled by the device for you. Percentages work as strings - width: '50%' - and flex: 1 means "take the remaining space", which is the single most useful value in mobile layout: it is how a list fills the screen between a header and a tab bar.
For sizes that depend on the device, useWindowDimensions is the hook to use, because it updates on rotation and on a foldable opening. The older Dimensions.get('window') reads once and is then stale.
Keep gap in mind. It works in React Native now and removes most of the margin arithmetic that layouts used to be full of.
import { View, Text, useWindowDimensions } from 'react-native';
export function Dashboard() {
// Updates on rotation and on a foldable opening. Dimensions.get does not.
const { width } = useWindowDimensions();
const columns = width > 600 ? 3 : 2;
return (
// Default flexDirection is 'column', so this stacks. flex: 1 fills
// whatever is left between the header and whatever is below.
<View style={{ flex: 1, padding: 16, gap: 16 }}>
{/* A row: explicit, because row is NOT the default here. */}
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<Text style={{ fontSize: 22, fontWeight: '700' }}>Today</Text>
<Text style={{ color: '#666' }}>{columns} columns</Text>
</View>
{/* flexWrap turns a row into a grid, with gap doing the spacing. */}
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 12 }}>
{[1, 2, 3, 4, 5, 6].map((n) => (
<View
key={n}
style={{
// No units: a number is a density-independent pixel.
width: `${100 / columns - 4}%`,
aspectRatio: 1,
borderRadius: 12,
backgroundColor: '#eef2f7',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Text>{n}</Text>
</View>
))}
</View>
{/* flex: 1 on the last child pushes the footer to the bottom. */}
<View style={{ flex: 1 }} />
<Text style={{ textAlign: 'center', color: '#999' }}>Pinned to the bottom</Text>
</View>
);
}
Open this example in the editor and change it. Nothing you type is saved.