Color
The Carbon color package helps teams build engaging digital experiences through consistent application of color.
Usage
Sass
The
@carbon/colors
@use '@carbon/colors';.selector {background: colors.$blue-50;}
For a full list of colors exported, refer to the API section in the package’s Sass Documentation.
In addition to individual colors, you can access all colors in a
Map
$colors
@use '@carbon/colors';@each $swatch, $grades in colors.$colors {@each $grade in $grades {//}}
Each key in the
$colors
Map
$colors: (blue: (10: #edf5ff,20: #d0e2ff,30: #a6c8ff,40: #78a9ff,50: #4589ff,60: #0f62fe,70: #0043ce,
JavaScript
For JavaScript, you can import and use this module by doing the following in your code:
// ESMimport { black, blue, warmGray } from '@carbon/colors';// CommonJSconst { black, blue, warmGray } = require('@carbon/colors');
Each color swatch is exported as a variable, and each color name is also exported as an object that can be called by specifying grade, for example:
black;blue[50]; // Using the `blue` object.warmGray100; // Using the `warmGray100` variable.