How to use css modules (react semantic ui) in create react app?
I am using react semantic ui and I want to add margin left and margin top for Table component (i.e align it in center) I also want to reduce the cell size inside Table but my css is not working why so ? Do I need to add any css loader or scss loader ? I am not able to understand why is my CSS code not working ?
Note: Table component has a prop called className and I want to make use of className prop and add custom styles. Link: https://react.semantic-ui.com/collections/table/#types-pagination
updatePage.js:
import React, { Component } from 'react';
import { Icon, Label, Menu, Table } from 'semantic-ui-react';
import faker from 'faker';
import s from './updatesPage.css';
const UpdatesPage = () => (
<Table celled className={s.updateForm}>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>URN number</Table.HeaderCell>
<Table.HeaderCell>Parish</Table.HeaderCell>
<Table.HeaderCell>Last Updated</Table.HeaderCell>
<Table.HeaderCell>Notes</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)
export default UpdatesPage;
updatePage.css:
.updateForm {
margin-top: 100px;
margin-left: 50px;
}
Above code is working i.e javascript is working but the CSS is not working why so ? See screenshot: https://imgur.com/a/sBEUA6J I am not able to see any margin top, left for table.
javascript html css reactjs
add a comment |
I am using react semantic ui and I want to add margin left and margin top for Table component (i.e align it in center) I also want to reduce the cell size inside Table but my css is not working why so ? Do I need to add any css loader or scss loader ? I am not able to understand why is my CSS code not working ?
Note: Table component has a prop called className and I want to make use of className prop and add custom styles. Link: https://react.semantic-ui.com/collections/table/#types-pagination
updatePage.js:
import React, { Component } from 'react';
import { Icon, Label, Menu, Table } from 'semantic-ui-react';
import faker from 'faker';
import s from './updatesPage.css';
const UpdatesPage = () => (
<Table celled className={s.updateForm}>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>URN number</Table.HeaderCell>
<Table.HeaderCell>Parish</Table.HeaderCell>
<Table.HeaderCell>Last Updated</Table.HeaderCell>
<Table.HeaderCell>Notes</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)
export default UpdatesPage;
updatePage.css:
.updateForm {
margin-top: 100px;
margin-left: 50px;
}
Above code is working i.e javascript is working but the CSS is not working why so ? See screenshot: https://imgur.com/a/sBEUA6J I am not able to see any margin top, left for table.
javascript html css reactjs
add a comment |
I am using react semantic ui and I want to add margin left and margin top for Table component (i.e align it in center) I also want to reduce the cell size inside Table but my css is not working why so ? Do I need to add any css loader or scss loader ? I am not able to understand why is my CSS code not working ?
Note: Table component has a prop called className and I want to make use of className prop and add custom styles. Link: https://react.semantic-ui.com/collections/table/#types-pagination
updatePage.js:
import React, { Component } from 'react';
import { Icon, Label, Menu, Table } from 'semantic-ui-react';
import faker from 'faker';
import s from './updatesPage.css';
const UpdatesPage = () => (
<Table celled className={s.updateForm}>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>URN number</Table.HeaderCell>
<Table.HeaderCell>Parish</Table.HeaderCell>
<Table.HeaderCell>Last Updated</Table.HeaderCell>
<Table.HeaderCell>Notes</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)
export default UpdatesPage;
updatePage.css:
.updateForm {
margin-top: 100px;
margin-left: 50px;
}
Above code is working i.e javascript is working but the CSS is not working why so ? See screenshot: https://imgur.com/a/sBEUA6J I am not able to see any margin top, left for table.
javascript html css reactjs
I am using react semantic ui and I want to add margin left and margin top for Table component (i.e align it in center) I also want to reduce the cell size inside Table but my css is not working why so ? Do I need to add any css loader or scss loader ? I am not able to understand why is my CSS code not working ?
Note: Table component has a prop called className and I want to make use of className prop and add custom styles. Link: https://react.semantic-ui.com/collections/table/#types-pagination
updatePage.js:
import React, { Component } from 'react';
import { Icon, Label, Menu, Table } from 'semantic-ui-react';
import faker from 'faker';
import s from './updatesPage.css';
const UpdatesPage = () => (
<Table celled className={s.updateForm}>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Name</Table.HeaderCell>
<Table.HeaderCell>URN number</Table.HeaderCell>
<Table.HeaderCell>Parish</Table.HeaderCell>
<Table.HeaderCell>Last Updated</Table.HeaderCell>
<Table.HeaderCell>Notes</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{faker.name.findName()}</Table.Cell>
<Table.Cell>{faker.random.number()}</Table.Cell>
<Table.Cell>{faker.address.streetAddress()}</Table.Cell>
<Table.Cell>{faker.date.weekday()}</Table.Cell>
<Table.Cell>{faker.random.words()}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
)
export default UpdatesPage;
updatePage.css:
.updateForm {
margin-top: 100px;
margin-left: 50px;
}
Above code is working i.e javascript is working but the CSS is not working why so ? See screenshot: https://imgur.com/a/sBEUA6J I am not able to see any margin top, left for table.
javascript html css reactjs
javascript html css reactjs
edited Nov 16 '18 at 5:17
fun joker
asked Nov 16 '18 at 4:56
fun jokerfun joker
604113
604113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The issue with line import css. While import the css no need to give the module name for it. Just change the import line as below, it will work
import './updatesPage.css';
Also change the code for className as below
<Table celled className='updateForm'>
Like sematic ui take priority while setting the css. So you need to change the priority in css add !important.
.updateForm {
margin-top: 100px !important;
margin-left: 50px !important;
}
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
|
show 1 more comment
In order to use CSS modules with create-react-app you need to rename your css file to updatesPage.module.css.
You can find documentation for this in the “Adding a CSS Modules Stylesheet” portion of the user guide
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331680%2fhow-to-use-css-modules-react-semantic-ui-in-create-react-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue with line import css. While import the css no need to give the module name for it. Just change the import line as below, it will work
import './updatesPage.css';
Also change the code for className as below
<Table celled className='updateForm'>
Like sematic ui take priority while setting the css. So you need to change the priority in css add !important.
.updateForm {
margin-top: 100px !important;
margin-left: 50px !important;
}
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
|
show 1 more comment
The issue with line import css. While import the css no need to give the module name for it. Just change the import line as below, it will work
import './updatesPage.css';
Also change the code for className as below
<Table celled className='updateForm'>
Like sematic ui take priority while setting the css. So you need to change the priority in css add !important.
.updateForm {
margin-top: 100px !important;
margin-left: 50px !important;
}
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
|
show 1 more comment
The issue with line import css. While import the css no need to give the module name for it. Just change the import line as below, it will work
import './updatesPage.css';
Also change the code for className as below
<Table celled className='updateForm'>
Like sematic ui take priority while setting the css. So you need to change the priority in css add !important.
.updateForm {
margin-top: 100px !important;
margin-left: 50px !important;
}
The issue with line import css. While import the css no need to give the module name for it. Just change the import line as below, it will work
import './updatesPage.css';
Also change the code for className as below
<Table celled className='updateForm'>
Like sematic ui take priority while setting the css. So you need to change the priority in css add !important.
.updateForm {
margin-top: 100px !important;
margin-left: 50px !important;
}
edited Nov 16 '18 at 6:54
answered Nov 16 '18 at 5:13
kumar kkumar k
34417
34417
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
|
show 1 more comment
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
I am using CSS modules in create react app.
– fun joker
Nov 16 '18 at 5:14
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
it is not working. Note: I am using react semantic ui and Table component has a className prop
– fun joker
Nov 16 '18 at 5:16
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
Change the classname too. I have edited the answer.
– kumar k
Nov 16 '18 at 5:18
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
No it doesn't work. Note: I am using react semantic ui -> react.semantic-ui.com/collections/table/#types-pagination
– fun joker
Nov 16 '18 at 5:23
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
Please take screenshot again and upload it here.
– kumar k
Nov 16 '18 at 5:32
|
show 1 more comment
In order to use CSS modules with create-react-app you need to rename your css file to updatesPage.module.css.
You can find documentation for this in the “Adding a CSS Modules Stylesheet” portion of the user guide
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
add a comment |
In order to use CSS modules with create-react-app you need to rename your css file to updatesPage.module.css.
You can find documentation for this in the “Adding a CSS Modules Stylesheet” portion of the user guide
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
add a comment |
In order to use CSS modules with create-react-app you need to rename your css file to updatesPage.module.css.
You can find documentation for this in the “Adding a CSS Modules Stylesheet” portion of the user guide
In order to use CSS modules with create-react-app you need to rename your css file to updatesPage.module.css.
You can find documentation for this in the “Adding a CSS Modules Stylesheet” portion of the user guide
edited Nov 16 '18 at 5:12
answered Nov 16 '18 at 5:05
Ryan CogswellRyan Cogswell
5,4611624
5,4611624
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
add a comment |
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
Do I need to make any changes in webpack.config file in node modules -> react scripts ?
– fun joker
Nov 16 '18 at 5:06
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
No, CRA using the file naming convention of *.module.css to indicate use of css modules, otherwise it interprets it as a regular css file.
– Ryan Cogswell
Nov 16 '18 at 5:08
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
It is not working why so ? screenshot : imgur.com/a/e3bsCvf
– fun joker
Nov 16 '18 at 5:11
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
I saw your updated answer and I am doing same thing but it is not working any idea how to reduce size of table and align it ? margin left and margin top not working
– fun joker
Nov 16 '18 at 5:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331680%2fhow-to-use-css-modules-react-semantic-ui-in-create-react-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown