Colors
#
OverviewThe Motor JS provides a base color system which can be edited to match your brand colors and style. All of the colors used in the framework are defined in our theme object, within global.color.
info
The global.color object is documented on the API section of the Theming page
Al of these colors can be referenced from our components or edited via our theme object. You can find an example of this below.
#
Referencing & Editing the base colorsIn the below example, the Box is referencing the brand color via the backgroundColor prop. This brand entry has also been edited in the Motor Component and changed to green.
You can try editing the live code below to change the brand color, or even, reference a different color. Try changing the backgroundColor prop to equal 'accent1', you'll see this reference the accent1 entry in the global.color object.
#
Open ColorMotor JS come bundled with Open Color (https://yeun.github.io/open-color/) an open source color scheme.
These are all stored in variables which can be accessed throughout the framework. See below for an example of how to reference the range of blues from open color.
var(--oc-blue-0)
var(--oc-blue-1)
var(--oc-blue-2)
var(--oc-blue-3)
var(--oc-blue-4)
var(--oc-blue-5)
var(--oc-blue-6)
var(--oc-blue-7)
var(--oc-blue-8)
var(--oc-blue-9)
#
KPI using a color variable from Open Color#
Using Colors in ChartsAll of our charts come with a colorTheme prop which enables you to customise their colors. This section will cover some examples.
#
Using the default color palettesOur base themes contain a number of default color palettes which are found in the base theme object, in global.colors. See below for some examples
#
Example using the divergent13 palette#
Example using the eco palette#
Using a color stringYou can pass a single color as a string, which will create an array of colors from Open Color. If there is no match with Open Color, the colors of the bar chart will default to black. If you want the chart to have a single color, pass an array of one color instead.
#
Using an array of colorsYou can pass an array of colors, to build your own color palette