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
I am not using webpack
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.
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.
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.
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.
Seems like a package possibly was not installed. Try these steps below:
1a. npm install semantic-ui-react
2a. npm install semantic-ui-css
1b. yarn add semantic-ui-react
2b. yarn add semantic-ui-css
In your index.js file add
import 'semantic-ui-css/semantic.min.css'
Now you should be ready! Run your app and you should see the styles, you may have to clear cache in some cases.
https://react.semantic-ui.com/usage/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With