Overview
During design and development, colors should be referenced by name. Using named colors has a few important benefits:
- More meaningful than hex values in mockups and code
- Encourages consistency and accessibility across the application
- Support for alternate themes
Some examples of named colors in the Kolibri Design System include:
tokens.textpalette.blacktokens.errorpalette.red.v_600tokens.primarybrand.primary.v_500brand.primary.v_600#2547F3brand.secondary.v_400#FFD533palette.grey.v_400#999999Care must be taken as we adjust the colors in the application. There are a number of considerations to take into account, including:
- Branding, aesthetics, and color harmony
- Sufficient contrast between foreground and background colors
- Accommodation of color blind users
- Maintainability and consistency of the application and code
- Amenability to theming by using tokens correctly
Usage
Colors can be referenced in two ways:
- CSS variables in
<style>blocks and SCSS files. Use these by default. - JavaScript accessors on Vue components, for inline
:stylebindings and for colors that need to be built at runtime (for example, a color combined with a custom opacity).
Both are set up by Vue.use(KThemePlugin) (see
Installation
) and stay in sync when brand colors change at runtime via
setBrandColors() or setTokenMapping().
CSS variables
Theme values are emitted as CSS variables on :root in three layers:
--tokens-*for named color tokens (e.g.--tokens-primary)--brand-*for brand color scales (e.g.--brand-primary-v500)--palette-*for the full palette (e.g.--palette-grey-v200)
Reference them directly with var(--name). For example, to color text using the
error token:
<div class="error-message">This is an error</div>
<style>
.error-message {
color: var(--tokens-error);
}
</style>
This will display:
For palette and brand variables, replace the dots in the path with hyphens and drop the
underscore (palette.grey.v_400 becomes --palette-grey-v400). Token
names are used as-is.
Computed styles
Colors are also available on every Vue component as JavaScript objects. Adding
Vue.use(KThemePlugin) makes the following objects available:
$themeBrandcontains colors related to the aesthetic color scheme$themeTokenscontains colors with special meanings in Kolibri$themePalettecontains a wide range of additional compatible colors
Use these for inline :style bindings and for values computed at runtime. For
example, to color text using $themeTokens.primary with a
computed style:
<div :style="{ color: $themeTokens.primary }">This is not an error</div>
This will display:
Move style definitions from the template to computed props if the style gets complex.
Computed classes
$computedClass can be used to dynamically create new classes for
pseudo-elements such as :hover or :focus. For example:
<input :class="$computedClass({ '::placeholder': { color: $themeTokens.annotation } })" >
This is usually not necessary, use a <style> block with
var(--tokens-*) for static pseudo-class colors.
Notation
In the references below we use the following shorthand:
brandrefers to$themeBrandin JavaScript, or--brand-*in CSStokensrefers to$themeTokensin JavaScript, or--tokens-*in CSSpaletterefers to$themePalettein JavaScript, or--palette-*in CSS
Darken utilities
You can apply darken utilities $darken1, $darken2, and
$darken3 to palette colors and tokens to achieve their darker shades. They are
available on every Vue component.
<div :style="{ backgroundColor: $themePalette.red.v_600 }">base</div>
<div :style="{ backgroundColor: $darken1($themePalette.red.v_600) }">$darken1</div>
<div :style="{ backgroundColor: $darken2($themePalette.red.v_600) }">$darken2</div>
<div :style="{ backgroundColor: $darken3($themePalette.red.v_600) }">$darken3</div>
base$darken1$darken2$darken3These utilities shouldn't be overused. Always check if there is a shade in the palette available that can be used instead.
Tokens
Color tokens are the most important set of named colors because they have a specific, well-defined usage within the application. Over time, our set of tokens should grow and shrink as necessary to fit the needs of the application.
Color tokens are by themselves abstract and defined by a purpose, not a color value. A theme makes them concrete by mapping them to specific brand colors and palette colors .
When using tokens, it's very important to choose them based on their semantic purpose, not because of their color values. This ensures that new themes can be created effectively.
Brand shortcuts
tokens.primarybrand.primary.v_500Default primary brand color. Commonly used for interactive elements
tokens.primaryDarkbrand.primary.v_600Default dark variant of the primary brand color. Commonly used for the hover state of interactive elements
UI Colors
tokens.successpalette.green.v_600Indicates the successful completion of an action in the application
Text
tokens.textpalette.black
Normal text color. (Typically used on top of the $themeTokens.surface color)
tokens.annotationpalette.grey.v_700
Text color with lower visual weight. (Typically used on top of the
$themeTokens.surface color)
tokens.textDisabledpalette.grey.v_300
Text color with lowest visual weight. (Typically used on top of the
$themeTokens.surface color)
tokens.textInvertedpalette.white
Text color for creating sufficient contrast when used on dark backgrounds (such as
$themeTokens.primary)
Learner activity
User-related labels
Content-related labels
tokens.practicepalette.blue.v_400tokens.watchpalette.lightblue.v_400tokens.listenpalette.pink.v_500tokens.readpalette.red.v_500tokens.explorepalette.orange.v_500tokens.createpalette.green.v_500tokens.reflectpalette.yellow.v_500tokens.topicpalette.grey.v_800Scales
A color scale – sometimes called a color ramp – is an evenly-spaced ramp of shades for a
particular color hue. In the Kolibri Design System, we follow
Google's Material convention
and segment colors into brightness levels, named v_50, v_100,
v_200, v_300, v_400, v_500,
v_600. Note that v_50 is only present on select color families:
palette.green.v_50#E5F9EBpalette.green.v_100#CCF4D8palette.green.v_200#99E9B1palette.green.v_300#66DD8Apalette.green.v_400#33D263palette.green.v_500#00C73Cpalette.green.v_600#00992EDue to the inconsistent way that humans perceive color and light, computing these scales is both art and science. It should not be done by simply sliding a "brightness" setting. We used materialpalettes.com to generate the scales for our primary and secondary brand colors. The same should be done for new themes.
Brand colors
Brand colors are chosen to reflect the mood, identity, or trademark of an application or an organization. The design system defines primary (dominant) and secondary (accent) branded color hues.
brand.primary.v_50#F5F7FFbrand.primary.v_100#D9E1FDbrand.primary.v_200#B4C3FBbrand.primary.v_300#8EA4F9brand.primary.v_400#6986F7brand.primary.v_500#4368F5brand.primary.v_600#2547F3Palette
A color palette is a set of generic base colors that cover a wide range of the color spectrum. We use the 2014 Material Design color palette, which has many colors to choose from.
In our design system, colors from the palette have names like pink,
grey, and amber.
With the exception of grey values, choosing arbitrary colors from the palette is only slightly better than choosing arbitrary hex values from the full color spectrum. No consistency or meaning is ensured, and they should generally be avoided in favor of specific color tokens and brand colors.
Grey values
A scale of standard greys
palette.white#FFFFFFpalette.black#000000palette.grey.v_50#FAFAFApalette.grey.v_100#F5F5F5palette.grey.v_200#E6E6E6palette.grey.v_300#CCCCCCpalette.grey.v_400#999999palette.grey.v_700#666666palette.grey.v_800#333333palette.grey.v_900#000000Full palette
The complete set of colors available in the palette
palette.red.v_50#FFECE9palette.red.v_100#FFD9D3palette.red.v_200#FFB4A7palette.red.v_300#FF8E7Cpalette.red.v_400#FF6950palette.red.v_500#FF4324palette.red.v_600#D21E00palette.pink.v_50#FFF2F3palette.pink.v_100#FFE5E8palette.pink.v_200#FFCCD1palette.pink.v_300#FFB2BBpalette.pink.v_400#FF99A4palette.pink.v_500#FF7F8Dpalette.pink.v_600#F76474palette.blue.v_50#F5F7FFpalette.blue.v_100#D9E1FDpalette.blue.v_200#B4C3FBpalette.blue.v_300#8EA4F9palette.blue.v_400#6986F7palette.blue.v_500#4368F5palette.blue.v_600#2547F3palette.lightblue.v_50#E5F5FDpalette.lightblue.v_100#CCEAFCpalette.lightblue.v_200#99D5FApalette.lightblue.v_300#66C1F7palette.lightblue.v_400#33ACF5palette.lightblue.v_500#0097F2palette.lightblue.v_600#0079C2palette.darkgreen.v_50#E5EEEBpalette.darkgreen.v_100#CCDDD6palette.darkgreen.v_200#99BBADpalette.darkgreen.v_300#669A85palette.darkgreen.v_400#33785Cpalette.darkgreen.v_500#005633palette.darkgreen.v_600#00331Epalette.green.v_50#E5F9EBpalette.green.v_100#CCF4D8palette.green.v_200#99E9B1palette.green.v_300#66DD8Apalette.green.v_400#33D263palette.green.v_500#00C73Cpalette.green.v_600#00992Epalette.orange.v_50#FFF1E5palette.orange.v_100#FFE4CCpalette.orange.v_200#FFC899palette.orange.v_300#FFAD66palette.orange.v_400#FF9133palette.orange.v_500#FF7600palette.orange.v_600#E56A00