DAY 39a: 8/FEB: CSS Modules
· This is a technique in React for locally scoping CSS by automatically generating unique class names for your styles. It helps avoid naming collisions and makes it easier to manage styles on a per-component basis.
#cssmodules#react#365DaysTechStreak
DAY 39b: 8/FEB: CSS Modules
· Create a CSS file for your component, & name it with the ‘.module.css’ extension eg NavBar.module.css
· Define styles: Define your styles using regular CSS syntax
/NavBar.module.css/
.container {
background: red;
padding: 10px;
}
#cssmodules#react
🚨💥 Performance concerns are a major bottleneck for Styled Components.
📊 But, CSS Modules offer better build performance by processing styles during the build time rather than at runtime.
#Performance#CSSModules
The more I test #Nextjs13#appDir and #Turbopack, the more unready it looks… I'm not talking "ready for prod", I'm talking "ready for anyone sane to use it for developing an obscure side project". The number of problems and bugs is insane (thread) #nextconf#nextjsconf#next13
#Nextjs#appDir renders a div wrapper for each path segment in the URL. No, I don't mean for each page or layout. For each path segment. i.e. /test -> 1 div, /test/test -> 2 divs, /1/2/3/4/5/6/7/8 -> 8 divs…
Imagine trying to style your layout but you have to account for an unknown number of nested divs inside. Furthermore, it's impossible to style them with #Tailwind or #CSSModules – only global CSS will work.
@FFumis@vercel Totally see where you're coming from.
But solution agnosticism has benefits too. E.g. React didn't come with a styling solution. Frustrating at first, but now, depending on our requirements we are free to use vanilla css, #CSSmodules, @tailwindcss, @emotioncss or @stitchesjs
Love this post by @dalmaer: It's exactly what we did @deutschetelekom. The first point: stick to #platform defaults is already gold. Instead of some css-in-js, just use #cssModules or plain #css. Sticking to the platform makes it easier in the long run.
One of the super strengths of #sketch2react is that it's so embedded into the @sketch ecosystem that, once you have learned a few simple rules, it flows very natural. No #plugin dependencies just a very handy #sketchassistant to aid you if you need 🤖💪
Dylan Attal is talking about CSS-Modules in React! Dylan is an SDG alum that gives back to the students and community. You can meet him at the monthly Whiteboard Challenge meetup he hosts,
#css#cssmodules#react#webdeveloper#webdevelopment
Hey @vite_js and @evanyou , I've encountered an issue with HMR and CSS MODULES. It seems the entire component re-renders with every CSS change. Is this intended behavior? #Vite#HMR#CSSModules 🐛
Just learned about CSS Modules while going through a React course. I can't believe I didn't know about it until now. All of the CSS rules in your <name>.module.css file is locally scoped to the component that is using it. Pretty nifty! #reactjs#cssmodules