1

I used create-react-app to initialize my app. Then I did npm install semantic-ui-react --save to install the package.

I want to create this Grid example from https://react.semantic-ui.com/collections/grid#grid-example-divided-number:

enter image description here

I created a file called Grid.js:

import React from 'react'
import { Grid } from 'semantic-ui-react'

const GridExample = () => (
  <Grid columns={3} divided>
    <Grid.Row>
      <Grid.Column>
        <p>Lorem Ipsum</p>
      </Grid.Column>
      <Grid.Column>
        <p>Lorem Ipsum</p>
      </Grid.Column>
      <Grid.Column>
        <p>Lorem Ipsum</p>
      </Grid.Column>
    </Grid.Row>

    <Grid.Row>
      <Grid.Column>
        <p>Lorem Ipsum</p>
      </Grid.Column>
      <Grid.Column>
        <p>Lorem Ipsum</p>
      </Grid.Column>
      <Grid.Column>
        <p>Lorem Ipsum</p>
      </Grid.Column>
    </Grid.Row>
  </Grid>
)

export default GridExample

Then in App.js I imported GridExample:

import React, { Component } from 'react';
import GridExample from './Grid'
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>

        <GridExample />

      </div>
    );
  }
}
export default App;

However, when the web page loads the <p> elements are stacked on top of each other - as if 6X1 instead of the intended 2X3

Why is the Grid not being rendered properly?

1 Answer 1

6

You are forgetting to add the CSS file.

According to the docs:

This is the quickest way to get started with Semantic UI React. You won't be able to use custom themes with this method.

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/semantic.min.css"></link>

See https://react.semantic-ui.com/usage#css for more options on how to reference it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.