How do you structure CSS in a large project?

Chloe Martin Chloe Martin il y a 2 semaines Résolu

Our stylesheet is 6,000 lines and every change breaks something. Do you use layers, BEM, utility classes? What actually worked for you?

2 Réponse

Use cascade layers for the big buckets (reset, base, components, utilities) and keep component styles next to the component. It took us a sprint to migrate and the breakages stopped.

Whatever you pick, write it down. A one-page guide matters more than the method.

BEM still works fine if everyone sticks to it.

Have you tried cascade layers? They took most of the specificity fights away for us.

Name things after what they are, not how they look. Saves you on every redesign.

Utility classes for spacing and layout, components for everything else. Works for a team of eight.

We moved to one file per component and it fixed most of our merge conflicts.