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 apply this to Responsive Web Design: if not too much changes then you can just change the values of CSS variables in your media queries.

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

Published by Bramus!

Bramus is a Freelance Web Developer from Belgium. 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.