As a “powerful, free Bootstrap starter theme for WordPress”, bootScore uses the color concept of Bootstrap by marking up its elements accordingly. Consequently, each bootScore instance initially starts with the same outfit. However, it also offers techniques to modify the default design so that a web designer can define and implement her customized colors in and with bootScore:
Solution
- Define the appearance of your site.
- Select the appropriate Bootstrap color clusters.
- Rewrite the function colors accordingly.
- Define your own CSS classes according to our goals.
- Assign these classes to the intended elements of your site.
Background
Bootstrap has divided the RGB color space into 10 color clusters: Blau (blue
), Indigo (indigo
), Violett (purple
), Rosa (pink
), Rot (red
), Orange (orange
), Gelb (yellow
), Grün (green
), Petrol (teal
), Cyan (cyan
), Grau (gray
).Blue (blue
), Indigo (indigo
), Violet (purple
), Pink (pink
), Red (red
), Orange (orange
), Yellow (yellow
), Green (green
), Petrol (teal
), Cyan (cyan
), Gray (gray
).
Each cluster starts with a corresponding light color and goes 9 steps up to a corresponding almost black color. The colors are defined as SASS variables, following the same pattern for each cluster. For example, we can access a
$green-100
, $green-200
, $green-300
, $green-400
, $green-500
, $green-600
, $green-700
, $green-800
, $green-900
, where $green
corresponds to the color $green-500
.
If we want to use these colors in one of our elements, we define a CSS class like .cdg600 { color: $green-600; }
in our child theme file scss/bscore_custom.scss
and assign it to the intended HTML element as herein <code class="cdg600">$green-600</code>
. Although this technique narrows the RGB color space, it makes it easier for us to create color-differentiated yet coordinated themes.
In addition to the purely technical color treatment, Bootstrap also breaks new ground conceptually: There would be — so the idea — cross-site communicative tasks that are (can be) performed by different elements of a site. Bootstrap allows you to assign typical “functional colors” to these functional elements. Eventually, the web designer decides which elements of a site take on which function — and assigns them the corresponding “functional color”.
Specifically, Bootstrap assumes that there are typically (several) elements in sites that signal success, deter, warn, or inform. Or that there are primary, secondary, or tertiary elements1, dark or light elements. Bootstrap defines ‘functional colors’ for these cross-page communicative functions. The corresponding Bootstrap-color-Howto shows the default assignment of these ‘functional colors’.
Hence, a Bootstrap-based theme only needs to mark up its elements according to the intended functions with the associated CSS classes to implement a minimal consistent color concept. This is provided by bootScore. However, it uses the default function colors of Bootstrap. Ultimately, this results in a rather ‘colorful’ color concept. However, we can align the colors by overwriting CSS definitions of the ‘function classes’ and thus transferring the conceptually appropriate color to all correspondingly marked elements. Bootscore demonstrates this approach by switching the primary color from blue to red — with the help of the ‘command’ $primary:#FF0000;
in the file bscore_variables.scss
.
However, we have to explicitly assign the value of the desired color instead of using one of the variables from the color clusters defined by Bootstrap. That’s not what we actually want. Intuitively we would write $primaty:$red;
. Unfortunately, that is not possible because the bootScore file bscore_variables.scss
is loaded before the corresponding Bootstrap file.2 Thus, for customizing the functional colors defined by Bootstrap and used by bootScore, we need to overwrite the existing definitions where we explicitly use the values of the intended cluster colors. To do that, we use our file bscore_variables.scss in our child theme.
However, redefining a function color implicitly also adjusts the dependent colors: If we set the primary color to red, the links become red, the background color of the badges becomes a lighter red, and their link text a darker red. But, bootScore ‘only’ passes the decisions of Bootstrap through.3
As compensation, we can then use all the predefined Bootstrap variables in our own CSS definitions we gather in our bootScore file bscore_custom.scss
. Moreover: we can assign the CSS classes predefined by Bootstrap (text|bg|...)-(primary|secondary|...|danger|...'
directly to our HTML elements for functionally coloring them according to our concept. And even further and finer: In our file bscore_custom.scss
, we can also overwrite existing classes — such as the CSS class card
by SASS-oriented definitions in the command card { backgroundcolor: var(--#{$prefix}dark);
to get a black background.4 This would ‘darken’ all the cards in our overview file.5
However, because we often don’t want to change all the elements that are marked with predefined classes, we end up using the traditional method again: we define new classes, using colors from the bootstrap clusters, and then assign them to the elements we intend to use in the templates. And how do we find these? By studying the source code of our previous bootscore pages — and trying things out.
To make a long story short: For creating a unified color concept, we must
- define our design goals — for example:
- The site should appear green-white-grey. => To get that, add to your file
bscore_custom.scss
$primary: #146c43; // $green-600
$secondary: #6c757d; // predefined value of $gray-600
$info: #0d6efd; // predefined value of $blue-500
- Prominent elements should appear purple (or dark red). => To get that, add to your file
bscore_custom.scss
$danger: #520dc2; // predefined value of $indigo-600
$warning: #8540f5; // predefined value of $indigo-400
$success: #20c997; // predefined value of $teal-500
- Secondary text should be legibly grayed out.
- The white article teasers should have a faint green border. => To get that, add to your file
bscore_custom.scss
.card { border-color: $green-600; }
- The teaser cards on our landing page should be presented on a slightly green background. => To get that, add to your file
bscore_custom.scss
.page-template-mylap , .hfeed { background-color: $blue-100;}
- The header and footer should continue to be gray, as it is by default designed by bootScore
- The site should appear green-white-grey. => To get that, add to your file
- select the Bootstrap color clusters we want to use (here: the clusters blue, purple, and grey).
- rewrite the functional colors accordingly — in our
bscore_variables.scss
file.6 - define your own CSS classes according to our goals — in our
bscore_custom.scss
file. - assign these classes to the intended elements of your site.7
CSS-class: bg-primary | CSS-class: text-primary |
CSS-class: bg-secondary | CSS-class: text-secondary |
CSS-class: bg-success | CSS-class: text-success |
CSS-class: bg-info | CSS-class: text-info |
CSS-class: bg-warning | CSS-class: text-warning |
CSS-class: bg-danger | CSS-class: text-danger |
CSS-class: bg-dark | CSS-class: text-dark |
CSS-class: bg-light | CSS-class: text-light |
And how does this …
… support our migration to bootScore? Well, once started with improving the image handling, a web designer will also notice the blurred ‘featured images’ of bootScore. She will try and refine solutions. And she may also tackle them with new HTML‑5 techniques. Because with that, a fancier image strategy combined with an integrated license fulfillment process and its own logo will really make sense. However, pictures bring colors to reading. So they should be integrated into a customized color concept. This post also contributes something to this topic.
- which probably refer to different degrees of importance [↩]
- bootScore says that by doing so it follows the Bootstrap guideline. [↩]
- Moreover, asked which element has got which function, bootScore recommends trying it out. [↩]
- or however we’ve defined the function color ‘dark’ [↩]
- Admittedly, this could also be done more simply, namely with the statement
.card { backgroundcolor: $dark}
[↩] - as shown in the table [↩]
- as described above [↩]