How to Implement Flexbox Layout in React Native?

Sep 29, 2022 . Admin

Now, let's see tutorial of react native flexbox flex property. Here you will learn how to use flexbox in react native . you can see layout with flexbox in react native. This tutorial will give you simple example of flexbox react native example. Let's see bellow example how to implement flexbox layout in react native.

In this example,We will learn flex css in react native.you can easy and simply use flex in react native.most useful css in react native.below's this example.

Step 1: Download Project

In the first step run the following command to create a project.

expo init ExampleApp
Step 2: App.js

In this step, You will open the App.js file and put the code.

import React from 'react';
import { View } from 'react-native';

export default function App() {
  return (
    <View style={{ flex: 1, flexDirection: 'column', padding: 40 }}>
      <View style={{ width: 50, height: 50, backgroundColor: 'red' }} />
      <View style={{ width: 50, height: 50, backgroundColor: 'yellow' }} />
      <View style={{ width: 50, height: 50, backgroundColor: 'green' }} />
    </View>
  );
}
Step 3: Run Project

In the last step run your project using the below command.

expo start

You can QR code scan in Expo Go Application on mobile.

Output:

It will help you...

#React Native