Utility classes are popular, but they are not an architecture. A list of bg-white p-6 rounded-lg text-gray-900 scattered across twenty components is not a design system. It is a collection of decisions waiting to collide.
SaaS projects grow fast. What starts as a landing page and a dashboard becomes a portal with settings pages, billing screens, admin tables, and onboarding flows. Without a CSS architecture, every new feature adds technical debt in the form of duplicated styles, overriding classes, and components that break when touched.
This is how to structure CSS for a SaaS project that will still be maintainable in twelve months.
Start with Design Tokens, Not Hex Codes
If you skipped the design token step, your CSS architecture is already fragile. Tokens are the single source of truth for color, spacing, typography, and border radius. Components should never reference raw hex values.
.button-primary {
background-color: var(--color-brand-primary);
color: var(--color-text-inverse);
padding: var(--spacing-control-tight) var(--spacing-control-medium);
border-radius: var(--radius-control-medium);
}
If your brand color changes from indigo to rose, you update one token. Every button, badge, and alert inherits the change. Without tokens, you are searching and replacing across components, hoping you did not miss one.
Define tokens at the root. Reference them in components. Never mix the two.
Layer Your CSS
Do not put everything in one file or one namespace. Organize by layer.
Layer 1: Base
Base styles reset browser defaults and set document-level typography.
html {
font-family: var(--font-sans);
line-height: 1.5;
color: var(--color-text-primary);
background-color: var(--color-background-primary);
}
a {
color: var(--color-brand-primary);
text-decoration: underline;
}
Base styles apply once. They should not reference component names.
Layer 2: Components
Components are discrete UI pieces: buttons, cards, modals, navigation bars, form inputs. Each component owns its layout and appearance.
.button {
display: inline-flex;
align-items: center;
justify-content: center;
padding: var(--spacing-control-tight) var(--spacing-control-medium);
font-size: var(--text-size-base);
font-weight: 500;
border: none;
border-radius: var(--radius-control-medium);
cursor: pointer;
transition: background-color 0.2s ease;
}
.button-primary {
background-color: var(--color-brand-primary);
color: var(--color-text-inverse);
}
.button-primary:hover:not(:disabled) {
background-color: var(--color-brand-primaryHover);
}
Components reference tokens and base styles. They do not reference other components directly. If a card needs to look like a button, give it its own class, not a copy of button styles.
Layer 3: Utilities
Utilities are single-purpose overrides: text-center, mt-4, flex, hidden. Use them for spacing adjustments and layout tweaks, not for building entire components.
.mt-4 {
margin-top: var(--spacing-4);
}
.flex {
display: flex;
}
.text-center {
text-align: center;
}
Utilities are the escape hatch, not the foundation. If you find yourself writing ten utility classes on every element, you are missing a component abstraction.
Name Components by Function, Not Appearance
Bad component names describe what something looks like:
.red-button.big-card.shadow-box
Good component names describe what something does:
.button-primary.card-product.modal-confirm.input-email
When the design changes from red to rose, .red-button becomes a lie. .button-primary remains true.
Use a consistent prefix if you are worried about collisions: .sedi-button, .sedi-card. Or rely on your component framework's scoping. Either way, be explicit.
Organize Files by Component, Not by Type
Do not put all CSS in one styles.css file. Do not separate files by buttons.css, cards.css, forms.css unless your project is tiny. Organize by feature or page:
styles/
base.css
tokens.css
components/
button.css
card.css
modal.css
input.css
utilities.css
Or, if you use a component-based framework, colocate styles with components:
components/
Button/
Button.vue
Button.css
Card/
Card.vue
Card.css
The goal is that deleting a component removes its styles without leaving orphans.
Handle Dark Mode with Token Swaps
Dark mode should not mean duplicating components. It means swapping token values.
:root {
--color-background-primary: var(--color-slate-50);
--color-text-primary: var(--color-slate-900);
--color-brand-primary: var(--color-indigo-600);
}
.dark {
--color-background-primary: var(--color-slate-950);
--color-text-primary: var(--color-slate-50);
--color-brand-primary: var(--color-indigo-400);
}
Components remain unchanged. A button using var(--color-background-primary) adapts automatically when .dark is applied to the document root.
If you use Tailwind, map tokens to config keys so bg-background-primary works in both light and dark modes without arbitrary values.
Avoid These Mistakes
Mistake 1: Utility-first everything
Utility classes are fast to write and hard to maintain. If every button in your app has six utility classes inline, changing the button style means editing every instance. Build a .button component instead.
Mistake 2: Nesting everything
Deep CSS nesting couples styles to DOM structure. If you move a component, its styles break. Keep nesting shallow. Prefer classes over descendant selectors.
/* Bad */
.sidebar .nav .item a:hover { ... }
/* Good */
.nav-item-link:hover { ... }
Mistake 3: !important as a habit
!important breaks the cascade and makes future overrides impossible. Use specificity deliberately. If you need to override a utility, create a component class with higher specificity, not !important.
Mistake 4: Ignoring dark mode until launch
Add dark mode tokens from day one. Retrofitting a component library is harder than building it with dark mode in mind.
Final Checklist Before Shipping
- Colors, spacing, and typography come from tokens, not hex codes
- Components have semantic names, not appearance names
- Base styles are separate from component styles
- Utilities are used sparingly, not as primary styling
- Dark mode variables exist and components reference them
- No
!importantin component stylesheets - Deleting a component removes its styles without orphans
- File organization matches component boundaries
Conclusion
CSS architecture is not about choosing Tailwind or Sass or plain CSS. It is about deciding where decisions live. Tokens own values. Components own appearance. Utilities own exceptions. When those boundaries are clear, your SaaS project can grow without its stylesheet collapsing under its own weight.
Build the architecture once. Every new page benefits from it.