Skip to main content

ZIndices

Interface

Structure

interface ZIndices {
[key: string]: number;
}

type ZIndex = keyof ZIndices;

Usage

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

Examples

Using the CLI compose command:

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

export default {
none: 0,
lowest: 10,
lower: 50,
low: 90,
high: 100,
higher: 120,
highest: 150
};

Or manually:

zIndices.ts
import { ZIndices } from '@morfeo/spec';

const zIndices: ZIndices = {
none: 0,
lowest: 10,
lower: 50,
low: 90,
high: 100,
higher: 120,
highest: 150
};
theme.ts
import { zIndices } from './zIndices';

const myTheme = {
zIndices,
...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
zIndexzIndex{ zIndex: "medium"} {"zIndex":50}

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

type MyZIndices = typeof zIndices;

declare module '@morfeo/spec' {
export interface ZIndices extends MyZIndices {}
}

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