Member-only story
Design Like a Pro: React Native Style Properties You Canโt Ignore ๐
4 min read 1 day ago
In this article we will learn about the important styles property that you must know in React Native.
1๏ธโฃ The Shape Shifter โ flex
๐ What it does?
Defines how a component should grow or shrink to fill available space.
๐ Usage:
flex: 1
โ Expands to take up all available space.flex: 0.5
โ Takes up half the space.
๐ Example:
<View style={{ flex: 1, backgroundColor: 'blue' }} />
2๏ธโฃ Align It Right โ alignItems
๐ What it does?
Aligns child elements along the cross-axis.
๐ Values:
flex-start
โ Aligns children to the start.center
โ Aligns children in the middle.flex-end
โ Aligns children at the end.stretch
โ Stretches children to fill.
๐ Example:
<View style={{ alignItems: 'center' }}>
<Text>Hello!</Text>
</View>