DEV Community

Discussion on: CSS Is Hard - How do you learn to use and write CSS properly?

Collapse
 
antjanus profile image
Antonin J. (they/them)

My own approach:

  1. use a preprocessors - even if it is PostCSS for the file imports/css bundling
  2. keep a settings file with colors and possibly typography and sizing
  3. write a general CSS framework to encompass most needs (a basic grid, buttons, etc.) and utilities. Make sure the utilities cannot be repurposed other than what they were built for.
  4. write component-specific CSS. Whether that's CSS-in-JS, BEM, or other approaches. Make sure to keep that CSS coupled only to those components

I've really liked the Tailwind approach to CSS which focuses on many MANY utilities that do exactly as they say. You're kind of writing CSS in HTML; however, a key difference is that Tailwind encourages composing their utilities into full components.