Flexbox
Last updated
Was this helpful?
Last updated
Was this helpful?
Flexbox is a system of positioning elements within the container. Developer can use flexbox to tell a react native how to position the elements within the the overall view tag. In default, react native will put the elements to the top left of its parent.
For example, if you want to centre the content, you may need 2 properties.
justifyContent
Used to move the element in vertical direction
Properties Setting
flex-end: push elements down to the very bottom
center: center middle
flex-start: default, top
alignItems
Used to move the element in horizontal direction
Properties Setting
flex-start: default, start of line
center: center of line
flex-end: end of line
Flexbox is also used to layout multiple items within the container.
For example, given we target to build the layout like this,
But by default, react-native will look like this,
Used to determine the item flow direction