Open In App

ReactJS Semantic UI Grid Collections

Last Updated : 17 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks.

In this article we will know how to use grid collections in ReactJS Semantic UI.

Types:

  • Divided: Grid can have dividers between its columns to separate them out from each other.
  • Vertically divided: Grid can also be vertically divided using vertical divider between the rows.
  • Celled: Grid can also contain rows that are divided into cells.
  • Internally divided: Grid can have rows divisions only between internal rows.

Syntax:

<Grid.Column />

 

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 semantic UI in your given directory.
     npm install semantic-ui-react semantic-ui-css

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: In this example, we will be going to use grid and icon element to display basic grid by using ReactJS Semantic UI Grid collections.

App.js




import React from 'react'
import {Grid, Icon} from 'semantic-ui-react'
  
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = 
document.head.appendChild(styleLink);
  
const btt = () => (
    <Grid celled>
      <Grid.Row>
        <Grid.Column width={7}>
          <Icon name='node'/>
        </Grid.Column>
        <Grid.Column width={8}>
          <Icon name='html5'/>
        </Grid.Column>
      </Grid.Row>
    
      <Grid.Row>
        <Grid.Column width={5}>
          <Icon name='js'/>
        </Grid.Column>
        <Grid.Column width={5}>
          <Icon name='react'/>
        </Grid.Column>
        <Grid.Column width={5}>
          <Icon name='angular'/>
        </Grid.Column>
      </Grid.Row>
    </Grid>
)
  
export default btt


Output:

Example 2: In this example, we are going to use grid and icon elements but we are Importing _ from lodash.

App.js




import _ from 'lodash'
import React from 'react'
import {Grid, Icon} from 'semantic-ui-react'
  
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = 
document.head.appendChild(styleLink);
  
const btt = _.times(5, (i) => (
  <Grid.Column key={i}>
    <Icon name='html5' size='big' />
    <Icon name='js' size='big' />
    <Icon name='react' size='big' />
    <Icon name='angular' size='big' />
  </Grid.Column>
))
  
  
const gfg = () => <Grid>{btt}</Grid>
  
export default gfg    


Output: 

Reference: https://react.semantic-ui.com/collections/grid



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads