Skip to main content

BorderWidths

Interface

Structure

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

type BorderWidth = keyof BorderWidths;

Usage

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

Examples

Using the CLI compose command:

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

export default {
none: '0px',
'2xs': '0.2px',
xs: '0.5px',
s: '1px',
m: '2px',
l: '4px',
xl: '6px',
'2xl': '8px',
};

Or manually:

borderWidths.ts
import { BorderWidths } from '@morfeo/spec';

const borderWidths: BorderWidths = {
none: '0px',
'2xs': '0.2px',
xs: '0.5px',
s: '1px',
m: '2px',
l: '4px',
xl: '6px',
'2xl': '8px',
};
theme.ts
import { borderWidths } from './borderWidths';

const myTheme = {
borderWidths,
...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
borderWidthborderWidth{ borderWidth: "m"} {"borderWidth":"2px"}
borderTopWidthborderTopWidth{ borderTopWidth: "m"} {"borderTopWidth":"2px"}
borderLeftWidthborderLeftWidth{ borderLeftWidth: "m"} {"borderLeftWidth":"2px"}
borderRightWidthborderRightWidth{ borderRightWidth: "m"} {"borderRightWidth":"2px"}
borderBlockWidthborderBlockWidth{ borderBlockWidth: "m"} {"borderBlockWidth":"2px"}
borderBottomWidthborderBottomWidth{ borderBottomWidth: "m"} {"borderBottomWidth":"2px"}
borderInlineWidthborderInlineWidth{ borderInlineWidth: "m"} {"borderInlineWidth":"2px"}
borderBlockEndWidthborderBlockEndWidth{ borderBlockEndWidth: "m"} {"borderBlockEndWidth":"2px"}
borderInlineEndWidthborderInlineEndWidth{ borderInlineEndWidth: "m"} {"borderInlineEndWidth":"2px"}
borderBlockStartWidthborderBlockStartWidth{ borderBlockStartWidth: "m"} {"borderBlockStartWidth":"2px"}
borderInlineStartWidthborderInlineStartWidth{ borderInlineStartWidth: "m"} {"borderInlineStartWidth":"2px"}

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

type MyBorderWidths = typeof borderWidths;

declare module '@morfeo/spec' {
export interface BorderWidths extends MyBorderWidths {}
}

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