Theming UI Components

Using BEM naming


Introducing First Class Theme Support

Each component needs to be aware that it may be used within a colour scheme so it needs to own the process of creating the various classes required to support different uses. Sometimes semantic classes are the way forward, but perhaps we should just allow the use of names to describe the particular style (think Solarized & Darcula, not Primary, Secondary, Success, etc.)

Names such as Primary, Secondary, etc. could and should be used to set other theme properties, such as size or font

Here we create a themes map, which contains the colour definitions for a variety of named themes. This makes it easier to re-use a colour scheme across components and removes the cases where two component madifier classes (with different names) confusingly implement the same colour scheme. e.g. no .btn--primary and .panel--brand which actually use the same colours

How we use this in practise:

Read more about this approach in my blog post - A Sassy Approach To Theming Components