Open In App

ReactJS UI Ant Design Row and Col Component

Ant Design Library has this component pre-built, and it is very easy to integrate as well. Row Component provides a way to represent a row in the grid system, and it is used to display data in the form of rows. Col Component provides a way to represent a Col in the grid system, and it is used to display data in the form of columns. We can use the following approach in ReactJS to use the Ant Design Row and Col Component.

Row Props:



Col Props:

Creating React Application And Installing Module:



Project Structure: It will look like the following.

Project Structure

Row Component Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.




import React from 'react'
import "antd/dist/antd.css";
import { Row } from 'antd';
  
export default function App() {
  
  return (
    <div style={{ display: 'block', width: 700, padding: 30 }}>
      <h4>ReactJS Ant-Design Row Component</h4>
      <Row style={{backgroundColor: 'red'
           width: '100%', height: 10}}></Row>
      <Row style={{backgroundColor: 'yellow'
           width: '100%', height: 10}}></Row>
      <Row style={{backgroundColor: 'blue'
           width: '100%', height: 10}}></Row>
    </div>
  );
}

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Column Component Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.




import React from 'react'
import "antd/dist/antd.css";
import { Row, Col } from 'antd';
  
export default function App() {
  
  return (
    <div style={{ display: 'block',
                  width: 700, padding: 30 }}>
      <h4>ReactJS Ant-Design Column Component</h4>
      <Row>
        <Col style={{
          backgroundColor: 'blue',
        }}>
          1st Column
        </Col>
        <Col style={{
          backgroundColor: 'orange',
        }}>
          2nd Column
        </Col>
        <Col style={{
          backgroundColor: 'pink',
        }}>
          3rd Column
        </Col>
      </Row>
    </div>
  );
}

Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Reference: 


Article Tags :