Skip to main content

Colors

Interface

Structure

interface Colors {
[key: string]: string;
}

type Color = keyof Colors;

Usage

// Types are re-exported for ease of use by other packages
// like @morfeo/core, @morfeo/web or @morfeo/react
import { Color, Colors } from '@morfeo/spec';

Examples

Using the CLI compose command:

colors.morfeo.ts
// Remove this line to add the slice to all of your themes
export const themeName = 'My Theme Name';
// Optional if you name the file colors.morfeo.ts
export const sliceName = 'colors';

export default {
dark: '#6C6C6C',
light: '#A3A3A3',
'gray.darkest': '#414141',
'gray.darker': '#575757',
'gray.dark': '#6C6C6C',
gray: '#828282',
'gray.light': '#A3A3A3',
'gray.lighter': '#C5C5C5',
'gray.lightest': '#E6E6E6',
'primary.lightest': '#dbe9ff',
'primary.lighter': '#92bdff',
'primary.light': '#4992ff',
primary: '#06f',
'primary.dark': '#0049b6',
'primary.darker': '#002c6d',
'primary.darkest': '#000f24',
'secondary.lightest': '#fae0f0',
'secondary.lighter': '#f0a1d1',
'secondary.light': '#e563b3',
secondary: '#db2494',
'secondary.dark': '#9c1a6a',
'secondary.darker': '#5e0f3f',
'secondary.darkest': '#1f0515',
error: '#d10343',
success: '#01ce80',
warning: '#fac656',
accent: '#23cedf',
disabled: '#bcbcbc',
white: '#ffffff',
black: '#000000',
background: '#ffffff',
invertedBackground: '#000000',
text: '#2f2f2f',
invertedText: '#ececec',
headText: '#000000',
invertedHeadText: '#ffffff',
};

Or manually:

colors.ts
import { Colors } from '@morfeo/spec';

const colors: Colors = {
dark: '#6C6C6C',
light: '#A3A3A3',
'gray.darkest': '#414141',
'gray.darker': '#575757',
'gray.dark': '#6C6C6C',
gray: '#828282',
'gray.light': '#A3A3A3',
'gray.lighter': '#C5C5C5',
'gray.lightest': '#E6E6E6',
'primary.lightest': '#dbe9ff',
'primary.lighter': '#92bdff',
'primary.light': '#4992ff',
primary: '#06f',
'primary.dark': '#0049b6',
'primary.darker': '#002c6d',
'primary.darkest': '#000f24',
'secondary.lightest': '#fae0f0',
'secondary.lighter': '#f0a1d1',
'secondary.light': '#e563b3',
secondary: '#db2494',
'secondary.dark': '#9c1a6a',
'secondary.darker': '#5e0f3f',
'secondary.darkest': '#1f0515',
error: '#d10343',
success: '#01ce80',
warning: '#fac656',
accent: '#23cedf',
disabled: '#bcbcbc',
white: '#ffffff',
black: '#000000',
background: '#ffffff',
invertedBackground: '#000000',
text: '#2f2f2f',
invertedText: '#ececec',
headText: '#000000',
invertedHeadText: '#ffffff',
};
theme.ts
import { colors } from './colors';

const myTheme = {
colors,
...restOfTheTheme,
};

morfeo.setTheme('My Theme Name', myTheme);

Properties

In this table is shown the property you pass to morfeo.resolve, the actual CSS property or properties that will be generated, an example of usage, and the correspondent output:

namecss propertyexampleoutput
bgbackgroundColor{ bg: "secondary.light"} {"backgroundColor":"#e563b3"}
fillfill{ fill: "secondary.light"} {"fill":"#e563b3"}
colorcolor{ color: "secondary.light"} {"color":"#e563b3"}
strokestroke{ stroke: "secondary.light"} {"stroke":"#e563b3"}
caretColorcaretColor{ caretColor: "secondary.light"} {"caretColor":"#e563b3"}
borderColorborderColor{ borderColor: "secondary.light"} {"borderColor":"#e563b3"}
outlineColoroutlineColor{ outlineColor: "secondary.light"} {"outlineColor":"#e563b3"}
borderTopColorborderTopColor{ borderTopColor: "secondary.light"} {"borderTopColor":"#e563b3"}
backgroundColorbackgroundColor{ backgroundColor: "secondary.light"} {"backgroundColor":"#e563b3"}
columnRuleColorcolumnRuleColor{ columnRuleColor: "secondary.light"} {"columnRuleColor":"#e563b3"}
borderLeftColorborderLeftColor{ borderLeftColor: "secondary.light"} {"borderLeftColor":"#e563b3"}
borderRightColorborderRightColor{ borderRightColor: "secondary.light"} {"borderRightColor":"#e563b3"}
borderBottomColorborderBottomColor{ borderBottomColor: "secondary.light"} {"borderBottomColor":"#e563b3"}

Extend Slice with custom properties

If you're using typescript and you add custom colors to your theme configuration, you'll need to merge the default Colors interface with your custom one. We suggest creating a declaration file (for example: morfeo.d.ts or types.d.ts) like the following one:

import { colors } from './path/to/your/custom/colors';

type MyColors = typeof colors;

declare module '@morfeo/spec' {
export interface Colors extends MyColors {}
}

Read more about how to extend the default Morfeo Theme here.