CSS Modules

·

1 min read

I wanted to try out new CSS things and in the State of CSS survey 2022 CSS Modules was pretty high up on the list.

I used it in a Vue project using Vite and I found it anticlimatic. Partly because Vite works with it without any extra work, and partly because it was a really simple project. But the only difference between using CSS and CSS Modules is that the file name ending was .module.css, rather than .css. That's it.

So it was very easy to use, but hard to see the point. What makes CSS Modules good is the ability to locally scope the styling. But with Vue you can do that with CSS, as you just import the CSS file you want to use with your component, then it's only used with that component.

So I didn't pick the best thing to use it on. But at least now it's not a total mystery and I know it's easy to use.