> ## Documentation Index
> Fetch the complete documentation index at: https://help.emaillove.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Design systems and your own components

> How the Email Love SDK reads design systems and documents, and how to add your own components.

The editor and the engine build every email from a design system. By default that's the Ultimate Email Design System, which is built in. You can pass your own, or add your own components to it.

This page is a summary. The full reference is [FORMAT.md](https://github.com/email-love/email-love-sdk/blob/main/packages/core/FORMAT.md) in the repository. `checkDesignSystem(designSystem)` from `@email-love/core/format` tells you what's wrong with a design system, in words.

## The built-in design system

`starterDesignSystem()` from `@email-love/core/starter` is the Ultimate Email Design System: its tokens and all 217 components, as a new Email Love account gets it. `starterEmails()` gives the four emails made from it. It's also [free on Figma](https://www.figma.com/community/file/1247396968159079452).

Most of its pictures are on Email Love's CDN. A few, like its logo and social icons, are served from `https://app.emaillove.com`. To serve those yourself, copy them and pass `assetBase: 'https://your.host'`. The same option sets where the carousel and accordion icons come from.

In the editor, leave out `designSystem` to use it. It's only loaded then.

## Documents

An email is a document:

```json theme={null}
{ "subject": "…", "preheader": "…", "blocks": [{ "id": "b1", "component": "ueds_basic_button", "version": 1, "fields": { "button_label": "Shop now" } }] }
```

* Each block names a component by its key and version, and holds its own field values.
* A field the block doesn't hold takes the component's default.
* `lang` (a language code) and `dir` (`ltr`, `rtl` or `auto`) are optional. Emails that read right to left render as a mirror image of their templates.

`cleanDocument` from `@email-love/core` gives the document as it's saved, or throws a `DocumentError`.

## Design systems

A design system is `{ "tokens": { … }, "components": [ … ] }`.

**Tokens** hold the brand styles:

| Key | Holds |
| - | - |
| `color`, `color_on` | Colors by role, like `primary`, `text` and `background`, and the ink that goes on them |
| `font` | `heading` and `body` fonts |
| `type` | Text styles, like `h1` to `h4`, `body` and `small` |
| `button` | Radius, padding, font size, weight and text transform |
| `layout` | Email width, gutters and section spacing |
| `logo`, `logo_on_dark` | Logo address, alt text and width |
| `social_icons`, `social_icons_on_dark` | An image address for each network |
| `direction` | Optional. `rtl` when the design system's emails read right to left |

**Components** each have:

* `key` and `name` (required). The key is unique in the design system.
* `version`, a whole number from 1. A changed component is a new version, and emails keep the version they use.
* `template` (required). MJML that starts with `<mj-wrapper>` or `<mj-section>`, with `{{field}}`, `{{{rich_text_field}}}` and `{{tokens.…}}` placeholders, and blocks for lists and conditions.
* `fields` (required). What a person can edit, in order.
* `category`, `zone`, `description`, `order` and `listed`, which say how an editor files and describes it.

**Fields** have a `key`, `type` and `label`. The types are `text`, `rich_text`, `link`, `image`, `select`, `color`, `number`, `boolean`, `list` and `code`. Link fields refuse `javascript:` and other unsafe addresses. Code fields refuse `<script>`. See FORMAT.md for each type's extra settings.

## Your own components

In the editor, pass them as `components`. They're added after the design system's. A component that can't be used is left out, and `onError` gets an error with `code: 'COMPONENT_PROBLEMS'` and a list of `problems`.

```jsx theme={null}
<EmailLoveEditor components={myComponents} email={email} images={images} />
```

Use `modules` to choose which component keys people can add.

With the engine, use `addComponents(designSystem, components)` from `@email-love/core/components`. It returns `{ designSystem, added, problems }`. Each problem says which component and why: `{ component, message }`. `componentProblems(component)` checks one component without adding it.

A few things to know:

* **Give your keys a prefix.** A key the design system already has is refused.
* **Pick a category.** `category` files the component in the editor's list: `header`, `hero`, `content`, `ecommerce`, `conversion`, `structure` or `footer`. Anything else goes under Other.
* **The MJML is checked later.** The template's MJML is checked when the email is drawn, not when the component is added.

## Your own design system

Pass `designSystem` to the editor, or to `renderEmail`, instead of the built-in one. Run `checkDesignSystem` on it first to see any problems.

[Read FORMAT.md on GitHub](https://github.com/email-love/email-love-sdk/blob/main/packages/core/FORMAT.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.