Skip to content
Related Articles

Related Articles

ReactJS MDBootstrap Columns Layout

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 20 Jan, 2022

MDBootstrap is a Material Design and bootstrap-based react UI library that is used to make good-looking webpages with its seamless and easy-to-use component.

In this article, we will know how to use Columns Layout in ReactJS MDBootstrap. Columns Layout allows the users to create columns, add styles to them and modify them based on user needs.

Syntax:

<MDBCol>...</MDBCol>

Creating React Application And Installing Module:

Step 1: Create a React application using the following command.

npx create-react-app foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command.

cd foldername

Step 3: Install ReactJS MDBootstrap in your given directory.

npm i mdb-ui-kit
npm i mdb-react-ui-kit

Project Structure: It will look like the following.

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

npm start

Example 1: This is the basic example that shows how to use Columns Layout.

App.js




import React from "react";
import {
  MDBContainer, MDBCol, MDBRow
} from "mdb-react-ui-kit";
  
export default function App() {
  return (
    <MDBContainer id='gfg'>
      <h2>GeeksforGeeks</h2>
      <h4>ReactJS MDBootstrap Columns Layout</h4>
      <div class="d-flex align-items-start text-light rounded bg-primary mb-3">
        <MDBCol>GeeksforGeeks</MDBCol>
        <MDBCol>GeeksforGeeks</MDBCol>
        <MDBCol>GeeksforGeeks</MDBCol>
      </div>
      <div class="d-flex align-items-start text-light rounded bg-warning mb-3">
        <MDBCol>React</MDBCol>
        <MDBCol>React</MDBCol>
        <MDBCol>React</MDBCol>
      </div>
      <div class="d-flex align-items-start text-light rounded bg-success mb-3">
        <MDBCol>MDBootstrap</MDBCol>
        <MDBCol>MDBootstrap</MDBCol>
        <MDBCol>MDBootstrap</MDBCol>
      </div>
    </MDBContainer>
  
  );
}

Output:

ReactJS MDBootstrap Columns Layout

Example 2: In this example, we will know how to add margin in Columns Layout.

App.js




import React from "react";
import {
  MDBContainer, MDBCol, MDBRow
} from "mdb-react-ui-kit";
  
export default function App() {
  return (
    <MDBContainer id='gfg'>
      <h2>GeeksforGeeks</h2>
      <h4>ReactJS MDBootstrap Columns Layout</h4>
  
      <MDBRow className='bg-warning text-light mb-3'>
        <MDBCol md='4' >
          Margin 4
        </MDBCol>
        <MDBCol md='4'>
        Margin 4
        </MDBCol>
      </MDBRow>
  
      <MDBRow className='bg-danger text-light mb-3'>
        <MDBCol md='3'>
        Margin 3
        </MDBCol>
  
        <MDBCol md='3'>
        Margin 3
        </MDBCol>
      </MDBRow>
  
      <MDBRow className='bg-success text-light mb-3'>
        <MDBCol size='auto'>
        Margin auto
        </MDBCol>
  
        <MDBCol size='auto'>
        Margin auto
        </MDBCol>
      </MDBRow>
    </MDBContainer>
  
  );
}

Output:

ReactJS MDBootstrap Columns Layout

Reference: https://mdbootstrap.com/docs/b5/react/layout/columns/


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!