Open In App

ReactJS Semantic UI Grid Collections

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:

Syntax:



<Grid.Column />

 

Creating React Application And Installing Module:

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.




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.




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


Article Tags :