Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
45
rated 0 times [  51] [ 6]  / answers: 1 / hits: 5358  / 5 Years ago, wed, november 14, 2018, 12:00:00

How can I add CSS for react semantic UI ? I am using create react app. I have installed semantic-ui-react and CSS CDN: https://react.semantic-ui.com/usage/?fbclid=IwAR3ZBaJfpxHGiNcAvophLp7IAPO-gHZfDvSOLs8h-n0-_29ncPoOdjwCX7o#content-delivery-network-cdn



loginForm.js:



import React from react;
import { Button, Form, Header } from semantic-ui-react;
import styles from './loginForm.css';

const LoginForm = () => (
<Form className={styles.formStyle}>
<Button className={styles.buttonStyle}>Login</Button>
</Form>
);

export default LoginForm;


loginForm.css:



.formStyle {
margin-left: 500px;
margin-top: 100px;
width: 550px;
}

.buttonStyle {
border-radius: 18px;
width: 200px;
background-color:#3865FE;
}


Above CSS code is not working for loginForm.js why so ? I also tried following :



<Form style={styles.formStyle}>
<Button style={styles.buttonStyle}>Login</Button>
</Form>


Above code is also not working.


More From » css

 Answers
5

Actually you're setting the value of className incorrectly.
Here is the modified version of your code.



import React from react;
import { Button, Form, Header } from semantic-ui-react;
import from './loginForm.css';

const LoginForm = () => (
<Form className='formStyle'>
<Button className='buttonStyle'>Login</Button>
</Form>
);

export default LoginForm;


and for loginForm.css



.ui.form.formStyle  {
margin-left: 300px ;
margin-top: 100px ;
width: 550px ;
height: 400px;
}

.ui.button.buttonStyle {
border-radius: 18px;
width: 200px;
background-color:#3865FE;
}


thanks @funJoker for suggesting me how to edit semantic-ui style.


[#10317] Monday, November 12, 2018, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
travion

Total Points: 137
Total Questions: 96
Total Answers: 103

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
travion questions
Mon, Dec 16, 19, 00:00, 4 Years ago
Sat, Oct 19, 19, 00:00, 4 Years ago
Fri, Sep 20, 19, 00:00, 5 Years ago
Sun, Oct 28, 18, 00:00, 5 Years ago
Sun, Oct 28, 18, 00:00, 5 Years ago
;