Skip to main content

Borders

Interface

Structure

type BorderConfig = {
width?: BorderWidth;
color?: Color;
style?: BorderStyle;
};

interface Borders {
[key: string]: BorderConfig;
}

type Border = keyof Borders;

Usage

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

Examples

Using the CLI compose command:

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

export default {
none: {
width: 'none',
style: 'none',
},
strong: {
width: 'm',
style: 'solid',
color: 'text',
},
medium: {
width: 's',
style: 'solid',
color: 'text',
},
thin: {
width: 'xs',
style: 'solid',
color: 'text',
},
};

Or manually:

borders.ts
import { Borders } from '@morfeo/spec';

const borders: Borders = {
none: {
width: 'none',
style: 'none',
},
strong: {
width: 'm',
style: 'solid',
color: 'text',
},
medium: {
width: 's',
style: 'solid',
color: 'text',
},
thin: {
width: 'xs',
style: 'solid',
color: 'text',
},
};
theme.ts
import { borders } from './borders';

const myTheme = {
borders,
...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
borderborder{ border: "primary"} {"border":"2px solid #2f2f2f"}
borderTopborderTop{ borderTop: "primary"} {"borderTop":"2px solid #2f2f2f"}
borderLeftborderLeft{ borderLeft: "primary"} {"borderLeft":"2px solid #2f2f2f"}
borderRightborderRight{ borderRight: "primary"} {"borderRight":"2px solid #2f2f2f"}
borderBlockborderBlock{ borderBlock: "primary"} {"borderBlock":"2px solid #2f2f2f"}
borderBottomborderBottom{ borderBottom: "primary"} {"borderBottom":"2px solid #2f2f2f"}
borderInlineborderInline{ borderInline: "primary"} {"borderInline":"2px solid #2f2f2f"}
borderBlockEndborderBlockEnd{ borderBlockEnd: "primary"} {"borderBlockEnd":"2px solid #2f2f2f"}
borderInlineEndborderInlineEnd{ borderInlineEnd: "primary"} {"borderInlineEnd":"2px solid #2f2f2f"}
borderBlockStartborderBlockStart{ borderBlockStart: "primary"} {"borderBlockStart":"2px solid #2f2f2f"}
borderInlineStartborderInlineStart{ borderInlineStart: "primary"} {"borderInlineStart":"2px solid #2f2f2f"}

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

type MyBorders = typeof borders;

declare module '@morfeo/spec' {
export interface Borders extends MyBorders {}
}

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