cssstylingfrontendui

Mental Overhead of Custom Global Classes in CSS

I've worked on projects with hundreds of custom CSS classes like .helper-12 and .util-spacing-3. Can you guess what they do? Neither could I.

·4 min read

I've worked on projects with hundreds of custom global CSS classes. Classes like .helper-12, .util-spacing-3, and .box-style-alt. Can you guess what each one does? Neither could I without checking the stylesheet every single time.

This mental overhead slows development and makes maintaining CSS miserable. Let me explain why custom global classes create problems and what works better.

The Problem With Custom Global Classes

You Have To Remember Everything

Unlike standardized utility classes (like Tailwind's p-4 or text-center), custom classes have arbitrary names. What does .content-wrapper-2 do differently from .content-wrapper-3? You'll need to look it up. Every. Single. Time.

I joined a project once with over 300 custom utility classes. Onboarding took weeks longer than it should have because I had to memorize (or constantly reference) what .spacing-helper-alt meant versus .spacing-helper-v2.

Ambiguous Purposes

Even well-named classes can be unclear. Does .btn-primary include hover states? What about focus? Active? You won't know until you read the CSS.

Compare this to Tailwind where hover:bg-blue-600 is self-explanatory. You know exactly what it does and when it applies.

Documentation Becomes Critical

With custom classes, you need documentation. But documentation gets out of date. Classes get renamed or removed, but docs lag behind. Now you're debugging why .deprecated-style-v1 still exists in the codebase but not in the docs.

I've spent hours tracking down class definitions in sprawling stylesheets. It's not fun.

Fear of Making Changes

Large codebases with custom global classes create anxiety. Is this class used elsewhere? Will changing it break something? You hesitate to modify styles, leading to more classes being added instead of refactoring existing ones.

This CSS bloat compounds over time. You end up with hundreds of barely-different classes doing nearly the same thing.

What Works Better

After years of fighting custom global classes, here's what I use instead:

Scoped Styles - Keep It Local

Vue's <style scoped> or CSS Modules keep styles attached to components. No global classes to remember. No conflicts. No mental overhead.

<template>
  <button class="btn">Click Me</button>
</template>

<style scoped>
.btn {
  padding: 10px 20px;
  background: blue;
  color: white;
}
</style>

The .btn class only exists in this component. I can use simple, clear names without worrying about conflicts elsewhere.

CSS Variables - Centralize Values

Instead of custom classes for every color and spacing variation, use CSS variables:

:root {
  --color-primary: #007bff;
  --spacing-base: 16px;
  --spacing-large: 24px;
}

.button {
  background-color: var(--color-primary);
  padding: var(--spacing-base);
}

One source of truth. Change the variable, update everywhere. No remembering which class applies which shade of blue.

Utility-First CSS - Predictable and Standardized

Tailwind's utility classes follow consistent patterns. Once you learn the system, you know it. p-4 means padding, text-lg means large text, bg-blue-500 means blue background shade 500.

No custom names to memorize. No hunting through stylesheets. The classes are self-documenting.

This reduced mental overhead massively on my projects. New developers were productive immediately because they didn't need to learn project-specific class names.

CSS-in-JS - Dynamic When Needed

For components with state-dependent styles, CSS-in-JS or Vue's :style bindings work great:

<template>
  <div :style="{ padding: paddingSize }">
    <slot />
  </div>
</template>

<script>
export default {
  props: {
    paddingSize: {
      type: String,
      default: '16px'
    }
  }
}
</script>

Styles stay with the component. No global classes. Clear props control styling.

My Current Approach

Here's how I structure CSS now to minimize mental overhead:

  1. Limit global styles - Only base typography, colors, and design tokens go in global scope
  2. Use scoped styles - Component-specific styles stay in components
  3. Prefer utility frameworks - Tailwind for layout and common patterns
  4. CSS variables for theming - One place to define colors, spacing, fonts

This combination gives me:

  • Less to remember - No custom global classes to memorize
  • Faster development - Predictable utilities, scoped styles
  • Easier maintenance - Clear component boundaries, standard patterns
  • Better collaboration - New team members productive quickly

The Reality Check

Custom global classes made sense when CSS didn't have better options. Now we have scoped styles, CSS Modules, utility frameworks, and CSS variables. We don't need project-specific naming conventions that create cognitive burden.

Every minute spent looking up what .helper-v2-alt does is a minute not spent building features. Choose tools and patterns that reduce mental overhead, not increase it.

Your future self (and your teammates) will thank you.