Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Semantic-ui-react style not loaded

I am trying to learn react with semantic ui but I have a problem with the style from semantic ui. Then I try follow the docs from https://react.semantic-ui.com/ but the style is not loaded

Here's my code

import React, { Component } from 'react';
import { Table, Icon, Menu, Label } from 'semantic-ui-react';

class App extends Component {

  // Here's my other code

  render() {
    const data = this.state.data
      if (this.state.error) {
        return (<p>Error : {this.state.error.message}</p>);
      } else if (!this.state.isloaded) {
        return (<p>Loading ...</p>);
      } else {
        return (
          <Table celled>
            <Table.Header>
              <Table.Row>
                <Table.HeaderCell>Network</Table.HeaderCell>
                <Table.HeaderCell>Address</Table.HeaderCell>
                <Table.HeaderCell>Balance</Table.HeaderCell>
              </Table.Row>
            </Table.Header>

            <Table.Body>
              <Table.Row>
                <Table.Cell>
                  <Label ribbon>{data.network}</Label>
                </Table.Cell>
                <Table.Cell>{data.address}</Table.Cell>
                <Table.Cell>{data.confirmed}</Table.Cell>
              </Table.Row>
            </Table.Body>

            <Table.Footer>
              <Table.Row>
                <Table.HeaderCell colSpan='3'>
                  <Menu floated='right' pagination>
                  <Menu.Item as='a' icon>
                    <Icon name='chevron left' />
                  </Menu.Item>
                  <Menu.Item as='a'>1</Menu.Item>
                  <Menu.Item as='a'>2</Menu.Item>
                  <Menu.Item as='a'>3</Menu.Item>
                  <Menu.Item as='a'>4</Menu.Item>
                  <Menu.Item as='a' icon>
                    <Icon name='chevron right' />
                  </Menu.Item>
                </Menu>
              </Table.HeaderCell>
            </Table.Row>
          </Table.Footer>
        </Table>
      );
    }
  }
}

Here's the result
Only text not with style

I am not using webpack

like image 470
MR. A Avatar asked Jan 08 '19 06:01

MR. A


People also ask

How add semantic UI in React JS?

Option 1: Package Managerx require Semantic UI React >=0.81. 0. The Semantic UI CSS package is automatically synced with the main Semantic UI repository to provide a lightweight CSS only version of Semantic UI. If you are using TypeScript, you don't need to install anything, typings are included with the package.

How do you customize semantic UI?

Building the custom styles First you need to build the files in the semantic folder and then include the generated CSS in your main application file. Since this is not something you want to do manually do every time, let's update the scripts in the package. json file to build the Semantic UI files.

Is Semantic UI customizable?

Semantic provides several ways to modify UI elements. For big projects that rely on building a personalized brand-aware visual language, site themes allow you to modify the underlying variables powering Semantic UI, as well as specify alternative overriding css.

How do I download semantic UI React?

Open this project in Visual Studio Code and install semantic UI using the following command. Install Semantic UI by using the following command, npm install semantic-ui-react.


1 Answers

Seems like a package possibly was not installed. Try these steps below:

Adding the packages with NPM

1a. npm install semantic-ui-react

2a. npm install semantic-ui-css

Adding the packages with Yarn

1b. yarn add semantic-ui-react

2b. yarn add semantic-ui-css

Project setup

In your index.js file add

import 'semantic-ui-css/semantic.min.css'

Running your project

Now you should be ready! Run your app and you should see the styles, you may have to clear cache in some cases.




Further Reading

https://react.semantic-ui.com/usage/

like image 149
SakoBu Avatar answered Sep 21 '22 20:09

SakoBu