#Behavior when importing normal CSS files in components
13 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
the css becomes available to all pages using that component. so if you declare .your-class you can use className="your-class" in those pages
note that the above applies to non-module css. .module.css files then check the docs
also note that importing non-module css files to any arbitrary component only works if
- you use the app router, or
- you use the pages router and the css file is inside
node_modules(so not a local css file, but a third party css file)
I use app router and yes, I meant non-module css.
Does CSS have effect until the page is refreshed once loaded by any component?
And does it intelligently not load the CSS files multiple times?
i don't know fully how it works behind the scenes, but in my current understanding of it, it's equivalent to importing that css file to the root layout except the css only takes effect for pages using that component
it's available before the page is mounted just like global css
this one idk at all but likely yes. you can try it
okay thank you, and there’s no documentation for this I guess?
Probably I should create an issue/discussion on the repo to ask whether I can rely on its behavior
check this which has this sentence which is related to this question
Global styles can be imported into any layout, page, or component inside the app directory.
yes you can rely on it, the above sentence should affirm it
okay, thank you!