Skip to main content

LetterSpacings

Interface

Structure

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

type LetterSpacing = keyof LetterSpacings;

Usage

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

Examples

Using the CLI compose command:

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

export default {
body: '0.01em',
heading: '0.02em',
};

Or manually:

letterSpacings.ts
import { LetterSpacings } from '@morfeo/spec';

const letterSpacings: LetterSpacings = {
body: '0.01em',
heading: '0.02em',
};
theme.ts
import { letterSpacings } from './letterSpacings';

const myTheme = {
letterSpacings,
...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
letterSpacingletterSpacing{ letterSpacing: "heading"} {"letterSpacing":"0.02em"}

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

type MyLetterSpacings = typeof letterSpacings;

declare module '@morfeo/spec' {
export interface LetterSpacings extends MyLetterSpacings {}
}

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