DEV Community

Cover image for CSS is Emotional: CSS Custom Properties - The Art of Self-Expression
EIO • Emmanuel Imolorhe
EIO • Emmanuel Imolorhe

Posted on

6 3 2 2 2

CSS is Emotional: CSS Custom Properties - The Art of Self-Expression

After almost a decade in frontend development, I've discovered that the concept of CSS custom properties is more than just technical variables—it's a profound means of emotional and design expression. Here are the key lessons I've learned about turning code into a deeply personal medium of communication.

Lesson 1: Naming is Power

Working across multiple design systems, I've watched our naming conventions evolve from being purely functional to deeply expressive:

:root {
  --color-blue-500: #0056b3;
  --color-red-500: #dc3545;
  --spacing-4: 16px;
  --spacing-6: 24px;
}
Enter fullscreen mode Exit fullscreen mode
:root {
  --color-primary: #0056b3;
  --color-danger: #dc3545;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
}
Enter fullscreen mode Exit fullscreen mode

The values haven't changed, but the intent has been made explicit. When a developer reaches for --color-danger instead of --color-red-500, they're making an emotional choice, not just a visual one.

Lesson 2: The Cascade of Emotion

The CSS cascade improves our understanding of emotional complexity:

:root {
  --base-spacing: 16px;
}

.container {
  padding: var(--base-spacing);
}

.alert {
  --base-spacing: 24px;
  padding: var(--base-spacing);
}
Enter fullscreen mode Exit fullscreen mode
<body>
  <div class="container">
    <p>Default container with 16px padding</p>
  </div>

  <div class="alert">
    <p>Alert with 24px padding</p>
  </div>
</body>
Enter fullscreen mode Exit fullscreen mode

Just as emotions inherit and transform through different contexts, custom properties can be redefined at different levels of specificity. The same property can mean something subtly different depending on its context—exactly how our emotional responses shift based on environment.

Lesson 3: Computed Values Create Relationships

I learned that custom properties aren't just static values—they can be dynamically calculated:

:root {
  --base-size: 16px;
  --scale-ratio: 1.25;
  --h1-size: calc(var(--base-size) * var(--scale-ratio) * var(--scale-ratio));
  --h2-size: calc(var(--base-size) * var(--scale-ratio));
}
Enter fullscreen mode Exit fullscreen mode

This mirrors how our emotions are rarely isolated—they're interconnected, scaling and transforming based on underlying core experiences. Each value is a relationship, not just a number.

Lesson 4: Dynamic Updates Reveal Adaptability

The true power of custom properties emerges in their ability to change dynamically:

:root {
  --interaction-sensitivity: 1;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --interaction-sensitivity: 0.5;
  }
}

.button {
  transition: transform calc(0.3s * var(--interaction-sensitivity));
}

.button:hover {
  transform: scale(calc(1.05 * var(--interaction-sensitivity)));
}
Enter fullscreen mode Exit fullscreen mode

Interfaces can now adapt their emotional tone in real-time, responding to user context just as humans adjust their emotional expression to different situations.

Lesson 5: @property - Defining Emotional Boundaries

The @property rule allows us to define not just values, but the very nature of our emotional variables:

@property --spring-bounce {
  syntax: '<number>';
  initial-value: 1;
  inherits: false;
}

.animation {
  --spring-bounce: 1.5;
  animation: bounce calc(0.5s * var(--spring-bounce)) ease-in-out;
}
Enter fullscreen mode Exit fullscreen mode

By constraining properties, we're creating emotional guardrails—defining how our design can and cannot express itself.

Lesson 6: Contextual Emotional Scoping

Different contexts call for different emotional expressions:

:root {
  --focus-intensity: 3px;
  --interaction-feedback: 0.2s ease-out;
}

.alert-critical {
  --focus-intensity: 4px;
  --interaction-feedback: 0.1s ease-in-out;
}

.alert-success {
  --focus-intensity: 2px;
  --interaction-feedback: 0.3s ease;
}
Enter fullscreen mode Exit fullscreen mode

The same element can feel urgent or calm depending on its context—just like our own emotional responses adapt to different situations.

Lesson 7: The Maintenance Reality

The emotional clarity of custom properties pays dividends during maintenance. Consider these two pull request examples:

/* Before: What does this change actually mean? */
- background-color: #f8f9fa;
+ background-color: #ffffff;

/* After: The emotional intent is clear */
- background-color: var(--surface-secondary);
+ background-color: var(--surface-primary);
Enter fullscreen mode Exit fullscreen mode

The second example communicates not just a color change but a shift from secondary importance to primary importance—critical context for code reviews. Each variable name now tells a story about importance, hierarchy, and feeling.

Conclusion: Code as a Canvas of Self-Expression

CSS custom properties are not just technical tools, but threads that connect design to human experience; a deeply personal medium through which we express our design philosophy, our understanding of user experience, and our belief in how interfaces should feel.

When we name a variable --color-calm instead of --color-sky-300, we're not just being poetic. We are preserving a design intention, expressing a belief that interfaces should feel welcoming, intuitive, and human.

Just as a painter uses brush strokes and color choices to communicate emotion, we can use property names, calculations, and dynamic updates to express our understanding of what makes interfaces meaningful.

Custom properties aren't just variables—they're set to be the vocabulary of your design language, telling stories of interaction, empathy, and human-centered design.

How have you seen your own expression evolve as CSS has developed?
Share your journey in the comments below.

Join us next time on our CSS is Emotional series: *"Debugging CSS: A Journey of Self-Discovery"***


Here's the CodePen used to design the banner 😊


About the Author

Emmanuel Imolorhe (EIO) is a Frontend Engineer passionate about CSS.
Check out my CSS videos on YouTube.

Connect with me

TwitterBlueskyMastodonLinkedInWebsite


Did this post help you? Have thoughts to share? Let's continue the conversation in the comments below!

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (2)

Collapse
 
moonieee profile image
Ashley Moon

Absolutely Amazing

Collapse
 
eioluseyi profile image
EIO • Emmanuel Imolorhe

Thank you!

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay