Skip to main content

Shadows

Interface

Structure

interface ShadowConfig {
color?: Color; // Refers to slice `colors`
offset?: {
width: BorderWidth; // Refers to slice `borderwidths`
height: BorderWidth; // Refers to slice `borderwidths`
};
radius?: Radius; // Refers to slice `radii`
opacity?: Opacity; // Refers to slice `opacities`
}

interface Shadows {
[key: string]: ShadowConfig;
}

type Shadow = keyof Shadows;

Usage

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

Examples

Using the CLI compose command:

shadows.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 shadows.morfeo.ts
export const sliceName = 'shadows';

export default {
none: {
color: 'gray',
opacity: 'light',
offset: {
height: 'none',
width: 'none',
},
radius: 'none',
},
light: {
color: 'gray.lightest',
opacity: 'light',
offset: {
height: 'xl',
width: 'none',
},
radius: 'l',
},
medium: {
color: 'gray.lighter',
opacity: 'light',
offset: {
height: 'xl',
width: 'none',
},
radius: 'l',
},
strong: {
color: 'gray.light',
opacity: 'light',
offset: {
height: 'xl',
width: 'none',
},
radius: 'l',
},
};

Or manually:

shadows.ts
import { Shadows } from '@morfeo/spec';

const shadows: Shadows = {
none: {
color: 'gray',
opacity: 'light',
offset: {
height: 'none',
width: 'none',
},
radius: 'none',
},
light: {
color: 'gray.lightest',
opacity: 'light',
offset: {
height: 'xl',
width: 'none',
},
radius: 'l',
},
medium: {
color: 'gray.lighter',
opacity: 'light',
offset: {
height: 'xl',
width: 'none',
},
radius: 'l',
},
strong: {
color: 'gray.light',
opacity: 'light',
offset: {
height: 'xl',
width: 'none',
},
radius: 'l',
},
};
theme.ts
import { shadows } from './shadows';

const myTheme = {
shadows,
...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
boxShadowboxShadow{ boxShadow: "medium"} {"boxShadow":"0px 6px 20px #C5C5C5"}
textShadowtextShadow{ textShadow: "medium"} {"textShadow":"0px 6px 20px #C5C5C5"}
shadowboxShadow{ shadow: "medium"} {"boxShadow":"0px 6px 20px #C5C5C5"}

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 Shadows 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 { shadows } from './path/to/your/custom/shadows';

type MyShadows = typeof shadows;

declare module '@morfeo/spec' {
export interface Shadows extends MyShadows {}
}

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