Theming with CSS Custom Properties (CSS Variables)

Stephanie Liu has replicated the native Slack theming capabilities in the browser using CSS Variables CSS Custom Properties. The essence of the demo is actually quite simple: define the variables on the :root level, and use ‘m where needed.

:root {
  --column-bg: #ae0001;
  --menu-bg-hover: #680001;
  --active-item: #D3A625;
  --active-item-text: #680001;
  --hover-item: #BE0002;
  --text-color: #FFFFFF;
  --active-presence: #00FFBA;
  --mention-badge: #DE4C0D;
}
.sidebar {
  background: var(--column-bg, #ae0001);
}

Here’s a full working demo:

See the Pen Slack Theming with CSS Custom Properties by Stephanie (@ramenhog) on CodePen.

💁‍♂️ You can also use this with Responsive Web Design / Media Queries: simply change the values of CSS Custom Properties in your Media Queries, et voila.

Theming with CSS Custom Properties →
Slack Theming with CSS Custom Properties →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation

3 Comments

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.