Actions and spans
Two inline components make an email actionable: :button for the one thing the reader should do, and :link for everything else. They are built into the engine, in every kit (D40). The kit decides how they look, through the action block in its blocks.html, and how many a template may use. Spans style a run of text with the classes the kit declares.
:button[Download invoice]{href="{{invoice_url}}"} :link[Billing settings]{href="https://example.com/billing"}
Your receipt for order EX-1042
From: Example <hello@example.com>
Add a button
:button[Label]{href="…"} is the primary action. Plain draws it as a square filled button; Quiet as a pill with a VML fallback, so it stays a button in Outlook for Windows.
- On its own. A
:buttonin a paragraph with other text is:button must stand alone in its paragraph. Put it on its own line, alone or with other actions. - Where actions are allowed. It sits in an action row, and only components whose content allows
actionstake one. See Build an action row. - Within the kit's limits. Quiet allows one
:buttonper template (more than one :button in the template) and none in aletter(letter: :button is not allowed here). Plain sets no limits.
Plain also has a ::button{href="…" label="…"} block component: a full-width button on phones, on a row of its own. It is a kit component like any other, with its own schema, and doesn't count as a :button.
Add a text link
:link[Label]{href="…"} is a text link. How it renders depends on where it is:
- In an action row, it is the kit's secondary action: bold, in the accent colour, with an arrow. Plain appends
→, Quiet›. A label that already ends in›gets no arrow added. - In running text, it is an ordinary link with no arrow, styled by the kit's
inline.link— the same as[Label](…).
We're lowering commission on services, as :link[the policy]{href="https://example.com/policies/fees"} explains.
:link[Read the full policy]{href="https://example.com/policies/fees"}
The first :link is inline; the second is alone in its paragraph, so it forms an action row. Both count against a kit's link limit.
Write the label and href
Both components take exactly one attribute, href, and a label:
| Rule | Applies to | Error |
|---|---|---|
href is required and not empty. | every :button and :link | :link: missing href |
| No other attributes. | every :button and :link | :link: unknown attribute "target" |
| The label is required. | actions in an action row | :button: missing label |
| The label is plain text and merge tags only — no emphasis, code or links. | actions in an action row | :link: label must be plain text |
A :link inside running text is an ordinary link, so its label is inline Markdown like any link text (:link[**bold**]{href="…"} compiles there).
href can hold merge tags. How their values are escaped, and which URLs are accepted at render, is in Know how URLs are escaped. A tag in a label is printed like any other merge tag, as in the tutorial kit's :button[Pay {{invoice.total}}]{href="{{pay_url}}"}.
Build an action row
A paragraph made only of :button and :link components, separated by spaces or line breaks, is an action row. It is a Markdown block of its own kind, actions, and a component takes one only when its schema's content.allow lists actions:
| Kit | Components that take action rows |
|---|---|
| Plain | section (so loose Markdown) and column |
| Quiet | statement, actions (exactly one row) and letter (links only) |
Anywhere else it is an error at the row, such as notice: action row is not allowed here. The kit's actions block lays the row out: side by side in Plain, stacked full width on phones in Quiet's statement and actions.
In the plain-text part, each action becomes its label with a colon, then its URL on the next line. From Plain's receipt sample:
Download invoice:
https://example.com/invoices/EX-1042
Billing settings:
https://example.com/billing
Link in running text
Inside paragraphs, list items and table cells, use ordinary Markdown links:
If you keep getting these, [secure your account]({{security_url}}).
Write to <help@example.com> or see <https://example.com/help>.
[text](url): the destination can hold merge tags. A link title ([text](url "title")) is an error unless the component opts in withcontent.inline: [link_title]; neither shipped kit does (section: link titles are not allowed).<https://…>: an autolink shows the address as its text.<name@example.com>: an email autolink becomes amailto:link.:link[text]{href="…"}in a sentence is the same as[text](…).
In the plain-text part, lttr writes a link as text (url), as the URL alone when the text is the URL, or as the address alone for an email autolink. A kit's inline text define can wrap that text.
Style text with spans
[text]{.class …} wraps inline Markdown in a style. The classes are the kit's own, declared under spans in kit.yaml, each setting a colour, a font, a size or a weight:
| Class | Plain | Quiet |
|---|---|---|
.muted | The muted text colour. | The secondary text colour. |
.accent | The accent colour. | — |
.teal | — | The action colour. Wins over .muted if both are set. |
.mono | The monospace font. | The monospace font. |
.small | 13 px type. | 13 px type. |
.bold | Bold weight. | Bold weight. |
::breakdown
| Delivery fee | [**{{fee}}**]{.teal} |
| --- | ---: |
| [Payment]{.small .muted} | [Buyer paid in app]{.small .muted} |
::
A class the kit doesn't declare is a compile error, unknown span class ".red", and a span accepts no #id or key=value (span: unknown attribute "#id"). The styles apply to the HTML part only; the plain-text part shows the text.
Spans are the only place a class may go. {.small} directly after a code span, a link or emphasis is attributes are only allowed on spans and inline components, so wrap the element in a span: [`{{order_id}}`]{.small}.
Next steps
- Components for the components that hold action rows.
- Compile errors for the full list of messages.