You can think of alignItems as justifyContent behaviour for cross axis. Cross-axis in case if React native is the horizontal axis. CSS alignItems property sets the alignSelf value on all direct children as a group. In Flexbox, it controls the alignment of items on the cross axis. By default, the cross axis is a horizontal axis in case of React native. We can use this property to layout elements in the flex container. The alignItems property supports following values: stretch|center|flex-start|flex-end|baseline|initial|inherit; Let me explain alignItems values:
- flex-start: this is the default value for alignItems. It means that flex items will start from the left and evenly distributed horizontally.
- Flex-end: this is just the opposite behaviour of flex-start. Elements start rendering from the right and go up to the left end.
- Center: Items will be placed in the middle
- Space-between: elements are evenly distributed along the cross axis (horizontal axis)
- Space-around: flex items will be evenly distributed with equal space around them
Leave a Reply