Kits

kit.yaml

Every key of kit.yaml — name, default component, dark mode, tokens, vars, spans, inline styles, limits, Go types and frontmatter — and how token names resolve.

kit.yaml sits at the root of the kit. It names the kit and holds everything the templates share: design tokens, copy constants, the styles of Markdown inlines, and the rules and Go types that apply to every template.

Know the keys

KeyValueWhat it does
namestring, requiredThe kit's name (Kit.Name()). lttr kit check prints it
versionintegerYour kit's version (Kit.Version(), 0 when absent). lttr gives it no meaning
defaulta component nameThe component loose top-level Markdown goes into. Without it, loose Markdown is a compile error
darktrue or falseThe kit supports dark mode. The lint then requires the color-scheme meta
tokensmappingDesign values: colours, fonts, sizes
varsmapping of stringsCopy constants such as the brand name. Config.Vars overrides them
spansmappingThe classes allowed in [text]{.class}
inlinemappingThe styles of links, code, strong, em and strike
limitsbutton, linkTemplate-wide caps on :button and :link
typeslistThe Go types components may bind
frontmattermappingThe kit's own frontmatter keys, typed like attributes

Any other key is a load error at its position:

Terminal
$ lttr kit check ./emailkit
emailkit/kit.yaml:11:1: unknown key "colour"

Name the kit

Plain's header sets the name, the default component and dark mode:

plain/kit.yaml#L1-L10
# Plain: a small, neutral starter kit for lttr.
#
# One left-aligned column on a light canvas, a system sans-serif stack,
# square buttons and light/dark colours. Copy it with `lttr kit init` and
# change anything: tokens here, markup in layout.html, blocks.html and
# components/*/html.tmpl.
name: plain
version: 1
default: section
dark: true

default must name one of the kit's components. dark: true means the kit carries a dark palette: see Email-safe HTML.

Define tokens

Tokens are the design values templates read with {{token "name"}}, or through {{style "prop" "name"}}. Plain's tokens are colours, two font stacks and sizes:

plain/kit.yaml#L12-L44
tokens:
  # Colour tokens may use any CSS colour syntax: a hex value, or a
  # function like rgb(47 111 235), rgba(31,35,40,0.9) or hsl(217 90% 70%).
  color.canvas:  { light: "#F6F8FA", dark: "#010409" }
  color.surface: { light: "#FFFFFF", dark: "#0D1117" }
  color.text:    { light: "#1F2328", dark: "#E6EDF3" }
  color.muted:   { light: "#59636E", dark: "#9198A1" }
  color.accent:  { light: "#2F6FEB", dark: "#4493F8" }
  color.button:  { light: "#2F6FEB", dark: "#2F6FEB" }
  color.on_button: { light: "#FFFFFF", dark: "#FFFFFF" }
  color.border:  { light: "#D1D9E0", dark: "#3D444D" }
  color.subtle:  { light: "#EFF2F5", dark: "#262C36" }
  # Quote family names with spaces in single quotes: "'Helvetica Neue',Arial,sans-serif".
  font.sans: "-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
  font.mono: "ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
  # Sizes in px. Templates cannot do arithmetic, so derived sizes get
  # their own token: keep size.content equal to size.width - 2 * size.side.
  size.width: 560        # the message column
  size.side: 32          # side padding of every component
  size.side_mobile: 16   # side padding below 600px
  size.content: 496      # size.width - 2 * size.side: the widest image
  size.block: 16         # space below every Markdown block
  size.gap: 32           # space below a component with no blocks
  size.text: 16
  size.line: 24
  size.small: 13
  size.small_line: 20
  size.h1: 28
  size.h1_line: 36
  size.h1_mobile: 24
  size.h1_mobile_line: 32
  size.h2: 20
  size.h2_line: 28
  • Names start with an ASCII letter, followed by letters, digits, _, - and .. The color., font. and size. prefixes are a convention, not a rule.
  • A colour is a mapping with light, dark or both. {{token}} gives the light value and {{dark}} the dark one.
  • Any other token is a single value.
  • Sizes are plain integers, in px by convention: templates write {{token "size.side"}}px. Templates cannot do arithmetic, so a derived size gets its own token, as the comment above size.width says.

Keep token values CSS-safe

Token values are written into styles.css unescaped, so a value may not be empty or contain <, >, {, }, ;, ", \ or a control character. A rejected token is then unknown to everything that names it:

Terminal
$ lttr kit check ./emailkit
emailkit/kit.yaml:26:14: tokens.font.mono: unsafe character '"' in "\"Menlo\",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
emailkit/kit.yaml:56:17: spans.mono.font: unknown token "font.mono"
emailkit/kit.yaml:62:26: inline.code.font-family: unknown token "font.mono"

Quote font family names with single quotes. The tutorial kit swaps Plain's system stack for a quoted one (this excerpt ends before the sizes, which are Plain's, unchanged):

tutorial/kit/kit.yaml#L14-L26
tokens:
  color.canvas:  { light: "#F6F8FA", dark: "#010409" }
  color.surface: { light: "#FFFFFF", dark: "#0D1117" }
  color.text:    { light: "#1F2328", dark: "#E6EDF3" }
  color.muted:   { light: "#59636E", dark: "#9198A1" }
  color.accent:  { light: "#1A7F37", dark: "#3FB950" }  # was Plain's blue
  color.button:  { light: "#1A7F37", dark: "#1A7F37" }  # was Plain's blue
  color.on_button: { light: "#FFFFFF", dark: "#FFFFFF" }
  color.border:  { light: "#D1D9E0", dark: "#3D444D" }
  color.subtle:  { light: "#EFF2F5", dark: "#262C36" }
  # Quote family names with spaces in single quotes: "'Helvetica Neue',Arial,sans-serif".
  font.sans: "'Helvetica Neue',Arial,sans-serif"  # was the system stack
  font.mono: "ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"

A quoted stack works because Plain's templates write fonts through the core style function, which accepts paired single quotes: {{style "font-family" "font.sans"}} renders font-family:'Helvetica Neue',Arial,sans-serif;. Written straight into a style attribute as font-family:{{token "font.sans"}}, the same token would be rejected by html/template's CSS filter and render as ZgotmplZ, which the lint reports:

Terminal
$ lttr kit check ./emailkit
emailkit/samples/receipt-free.md: html: contains "ZgotmplZ" at byte 5409 and 1 more (a value html/template rejected)
emailkit/samples/welcome.md: html: contains "ZgotmplZ" at byte 5396 (a value html/template rejected)
lttr kit check: ./emailkit: 2 problems

Write colours in any CSS syntax. A colour token may be #1A7F37, a keyword such as white, or a function: rgb(26 127 55), rgba(31,35,40,0.9), hsl(135 60% 50%). Plain, and every kit copied from it, writes colour tokens into style attributes through the same style function, {{style "color" "color.accent"}}, so a functional colour reaches the HTML intact. A colour in an HTML attribute such as bgcolor="{{token "color.canvas"}}" is escaped as text and is fine too. Only a colour written straight into a style attribute, as color:{{token "color.accent"}};, is rejected when it holds (, and the lint catches it. With color.accent: { light: "rgb(26 127 55)", … } and one link written that way in the footer:

Terminal
$ lttr kit check ./emailkit
emailkit/samples/receipt-free.md: html: contains "ZgotmplZ" at byte 13687 (a value html/template rejected)
emailkit/samples/welcome.md: html: contains "ZgotmplZ" at byte 10556 (a value html/template rejected)
lttr kit check: ./emailkit: 2 problems

The core button function is stricter: its fill and text colours must be #hex or a keyword, and anything else renders as ZgotmplZ. Plain's button component doesn't use it.

Resolve token names

A token name can stand in for a value in several places. Each resolves it the same way: a value that names a token becomes the token's value, the light value for a colour.

WhereExampleA name that is not a token
{{token "name"}} in a template{{token "size.text"}}A load error, token: unknown token "size.txt" (did you mean size.text?). A token with only a dark value is an error too
{{dark "name"}} in a template{{dark "color.canvas"}}A load error. So is a token with no dark value
{{style "prop" "value" …}} in an HTML template{{style "font-family" "font.sans"}}Written as a literal CSS value. A literal that reads as a token name in one of the kit's token groups, such as "color.txt", must be a token: a load error, style: unknown token "color.txt" (did you mean color.text?)
spans and inline in kit.yamllink: { color: color.accent }A dotted name that names no token is an error (unknown token, with a suggestion when a token is close). Anything else is a literal CSS value
spans.*.size and component spacingbottom: size.gapMust be a non-negative integer, or a token whose value is one

token, dark and var check a literal argument when the kit loads, and so does style for a literal value shaped like a token name. An argument computed in the template is checked when it renders.

Set vars

Vars are string constants for copy: the brand, the site URL, the sender's address.

plain/kit.yaml#L46-L51
vars:
  brand: Example
  site: https://example.com
  company: Example Inc.
  address: 100 Main Street, Springfield
  asset_base: https://example.com/assets
  • Templates read them with {{var "brand"}}. An unknown name is a load error: var: unknown var "compnay" (did you mean company?).
  • Config.Vars overrides them per renderer. Every key must be a kit var, and a value may not contain <, > or a control character, because vars can reach styles.css.
  • asset_base always exists, even when kit.yaml does not declare it. Config.AssetBase sets it, not Config.Vars. Plain builds its logo URL from it: {{var "asset_base"}}/logo.png.

See Profiles and config for Config.

Style spans and inline Markdown

spans lists the classes a template may use in [text]{.class}. inline styles the Markdown inlines:

plain/kit.yaml#L53-L64
spans:
  muted: { color: color.muted }
  accent: { color: color.accent }
  mono: { font: font.mono }
  small: { size: size.small }
  bold: { weight: bold }

inline:
  link:   { color: color.accent, text-decoration: underline }
  code:   { font-family: font.mono, font-size: 14px, background-color: color.subtle, padding: 1px 4px }
  strong: { font-weight: 600 }
  strike: { color: color.muted, text-decoration: line-through }
  • A span sets any of color, font and weight (a token name or a literal) and size (px, or a size token). Class names match [a-z][a-z0-9_-]*. A span with several classes combines them, later classes winning.
  • inline has one entry per inline kind: link, code, strong, em and strike. Each is an ordered mapping of CSS properties ([a-z-]+) to a token name or a literal, written into the element's style attribute in that order.
  • A class that spans does not declare is a compile error in the template: unknown span class ".loud". See Actions and spans.

limits caps the :button and :link inline components across a whole template. Plain sets none. With limits: { button: 1 }, a second :button is a compile error:

Terminal
$ lttr lint -kit ./emailkit templates/launch.md
templates/launch.md:12:1: more than one :button in the template

A component can set its own limits for the buttons and links inside its content. See Component schemas.

Register Go types

types lists the Go types that component bindings may name. The tutorial kit binds one:

tutorial/kit/kit.yaml#L10-L12
# Go types components may bind. The kit's Go package registers each one
# with kit.Types, so this kit loads from Go, not from the CLI.
types: [Invoice]

Every listed name must be registered from Go with kit.Types, or the kit does not load:

Terminal
$ lttr kit check examples/tutorial/kit
examples/tutorial/kit/kit.yaml:12:9: types: "Invoice" is not registered
examples/tutorial/kit: kit directories load without Go types; check kits that bind Go types from Go (see README)

See Go types and funcs.

Declare frontmatter keys

frontmatter declares keys a Markdown template may set in its frontmatter, besides the core template, profile, subject, preheader and from. Each key is typed exactly like a component attribute (type, required, required_with, default, values; see Component schemas). For example, frontmatter: { campaign: { type: enum, values: [spring, autumn] } } makes campaign: a checked key:

Terminal
$ lttr lint -kit ./emailkit templates/spring.md
templates/spring.md:5:1: frontmatter: "campaign" must be one of spring, autumn
  • Layouts and component templates read the value as .Doc.Front.campaign. Blocks do not see .Doc.
  • An unset key takes its default, else the zero value of its type: "" for text, url and enum, an empty list, 0, false, or a nil inline. So {{if .Doc.Front.campaign}} is false, and printing it writes nothing, never <no value>.
  • Redeclaring a core key is a load error: frontmatter: "subject" is a core key.

See Frontmatter for the template side.

Next steps

Copyright © 2026