Layout with Flexbox in React Native part-1

The Flexbox layout mechanism gives you an ability how you can construct the component in the layout. The Flexbox will solve the layout challenges. You can also use Flexbox with multiple components. Flexbox is also used to layout multiple items within the container as well.

So let’s see how we use Flexbox layout in the React Native app. Now let’s add the justifyContent property in the Flexbox. justifyContent have multiple values as listed below:

  • flex-start

flexDirection: ‘flex-start’

The Default behaviours of Flexbox is shown in the below diagram. And the JSX is like
<Image />
<Text />
<Text />
It’s basically left align and vertical(column) direction.

  • flex-end

flexDirection: ‘flex-end’

When add justifyContent: ‘flex-end’, the all content will shift down to bottom.

  • center

flexDirection: ‘center’

When adding justifyContent: ‘center’, all content will shift to the center of the layout.

  • space-between

flexDirection: ‘space-between’

If we add justifyContent: ‘space-between’, then the Flexbox will add equally space between all the elements. So the container takes all the elements and adds maximum equalize space between each element.

The first item is at the very top of a container and the last item is at very bottom of the container and then all the space in between the intermediate items is equalized so they are completely equal in between their last space around as much like space between.

  • space-around

flexDirection: ‘space-around’

Space around as much like space between but it also allocates item to the very the head of the very first item and after the very last item as well.

So, in theory, each of these white spaces in here one two three and four should be completely equal whenever we’re using space around.

We see the other property of Flexbox in next article.

Thanks for reading this article. Be sure to 👏 recommend as much as you can and also share with your friends. It means a lot to me.

For more about programming, follow me and Aubergine Solution, so you’ll get notified when we write new posts.