Next.js Discord

Discord Forum

Can't import Css

Answered
Chinese Alligator posted this in #help-forum
Open in Discord
Chinese AlligatorOP
Hello! I can't import the globals.css in the components folder
Answered by Clown
Read that page i linked again. You need to use the extension ".module.css"
View full answer

24 Replies

@Chinese Alligator Hello! I can't import the globals.css in the components folder
Why do you need to import it in the components folder :/
Just import it in your layout and it will be available to all the pages and in extension the components on the page
@Clown Why do you need to import it in the components folder :/
Chinese AlligatorOP
i want to change css on click
@Chinese Alligator i want to change css on click
Don't use global css for that then
create two css classes and switch between on click
@Clown create two css classes and switch between on click
Chinese AlligatorOP
heah thats what i was planning
but cant import it from the same folder either
You don't need to explicitly import it in the components
If you create the classes in the global css and its imported in the layout file, then those classes should be available to the components
Chinese AlligatorOP
so how do I call them?
You just use them like you normally use css classes
Chinese AlligatorOP
how do I reference it the same as "styles" in this code
That specific example is using css modules
Not global
Which is kinda better tbh since you dont need those specific styles for the entire site
Chinese AlligatorOP
okay i check it
Chinese AlligatorOP
@Clown it does not recognise it
@Chinese Alligator <@678259999201427466> it does not recognise it
Read that page i linked again. You need to use the extension ".module.css"
Answer
Chinese AlligatorOP
oh sh*t i missed that completly 😅
@Chinese Alligator oh sh*t i missed that completly 😅
If the problem's solved, mark the answer