How to install and use semantic-ui-react
Asked Answered
D

5

15

I want to build a web client using react.js and semantic ui. There is a node package to use semantic-ui with react.js; semantic ui react. I have already installed this package on my computer following the instructions on react.semantic-ui.com/usage, but upon testing the with a simple webpage.

I think I have this issue because I failed to use this last instruction: import '.../semantic/dist/semantic.min.css';. The semantic folder has been generated in my project main folder, but the dist folder and the semantic.min.css have not been generated yet. Where and how should I use this?

NB: I also tried adding this <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/semantic.min.css"></link> to my index.html page and the page was style as expected. I don't want to use this option as I cannot change the them with it.

Dilatory answered 25/11, 2016 at 10:43 Comment(2)
I have succeeded to generate the semantic/dist/* files. I don't know yet how to import '.../semantic/dist/semantic.min.css' and where to import it.Dilatory
semantic-ui-css is a package dependency of SUIRWhittling
I
29

First - install css npm install semantic-ui-css --save
Then - import in at the index.js page (the very top level)
import 'semantic-ui-css/semantic.min.css';

Indigence answered 17/10, 2017 at 11:1 Comment(3)
Though if you want a custom build (say a theme), you'd need to npm install semantic-ui and run the gulp build task (or add it to the CI) : semantic-ui.com/introduction/build-tools.htmlMythify
thanks. why does it have to import in the index.js page?Ummersen
just to be included in the final bundle, and be available everywhere.Indigence
F
6

First, use one of below package managers to install semantic UI react package.

For npm users:

npm install semantic-ui-react

For yarn users:

yarn add semantic-ui-react

Then add this import line to your index.js

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

That's all.

Frae answered 8/1, 2019 at 16:34 Comment(2)
From where does come "semantic-ui-css" ? There might be missing a npm install semantic-ui-cssMythify
@Mythify from the dependency of SUIR. No need to install it twice.Whittling
M
2

For npm user:

npm i semantic-ui-react semantic-ui-css
Murillo answered 19/5, 2019 at 12:35 Comment(0)
W
0

semantic-ui-css is a package dependency of Semantic-ui-react (SUIR) and is the css only distribution with a unique theme. Semantic-ui is written in Less and provides a larger and finer control (per component) over the production of the final stylesheet (dist/semantic.min.css). It delivers several themes easy to derive to create your own, and a proper picture about how to keep a big and complex css well organized and not invasive with less.

in node v12, the installation of sui-css may fail, complaining that ReferenceError: primordials is not defined. See https://mcmap.net/q/53483/-how-to-fix-quot-referenceerror-primordials-is-not-defined-quot-in-node-js.

You can also git clone https://github.com/semantic-org/semantic-ui apply the patch above in here. and yarn install

Note the default semantic.min.css size is 628Kb and you probably don't need the styling for all the components it has.

Whittling answered 27/5, 2020 at 4:15 Comment(0)
N
-1
npm install sematic-ui-react sematic-ui-css --save
Niveous answered 13/12, 2018 at 11:24 Comment(2)
How is your answer any way different from @DonskikhAndrei's?Dilatory
Same as Donskikh Andrej's answer.Gorton

© 2022 - 2024 — McMap. All rights reserved.