Templates
Print kit
Every template starts from one stylesheet: the print kit. It gives you embedded fonts, sensible type sizes in print units, and classes for the parts most business documents share. Tables repeat their header on each page and never split a row. You write little or no CSS.
The kit is always on for templates. For raw HTML, turn it on with options.kit.
#Settings
A template's settings set up the page. You can also override any of them for a single render in options.
| Setting | Default | Values |
|---|---|---|
page_size | A4 | A3, A4, A5, Letter, Legal, Tabloid |
orientation | portrait | portrait, landscape |
margin | 15mm 16mm 17mm | One to four CSS lengths (mm, cm, in, pt, px). Use 0 for full-bleed layouts. |
font | inter | inter (sans), source-serif (serif), jetbrains-mono (monospace), system |
heading_font | same as font | Same choices as font. |
accent | #111827 | A hex colour. Available in CSS as var(--accent). |
page_numbers | false | true prints "1 / 3" at the bottom right of each page. |
header_text | Text at the top left of each page. Up to 200 characters. | |
footer_text | Text at the bottom left of each page. Up to 200 characters. |
Fonts are embedded in the PDF, so documents look the same on every device. system embeds nothing and uses the renderer's default sans-serif.
#Document header
doc-head puts your brand on the left and the document title on the right.
<header class="doc-head">
<div class="brand">
<img class="logo" data-if="company.logo_url" src="{{ company.logo_url }}" alt="">
<div class="brand-name" data-unless="company.logo_url">{{ company.name }}</div>
<div class="small muted lines">{{ company.address }}</div>
</div>
<div class="doc-id">
<h1 class="doc-title">Invoice</h1>
<div class="doc-number">{{ number }}</div>
<dl class="meta">
<dt>Issued</dt><dd>{{ issue_date | date: "%b %-d, %Y" }}</dd>
<dt>Due</dt><dd>{{ due_date | date: "%b %-d, %Y" }}</dd>
</dl>
</div>
</header>| Class | Use |
|---|---|
doc-head | The header row. |
brand, logo, brand-name | Logo image (scaled to fit) or the company name as text. |
doc-id, doc-title, doc-number | Right-aligned title in the accent colour, with the document number under it. |
meta | A <dl> of label/value pairs. Add left to left-align it. |
label, kicker | Small uppercase caption above a block. |
#Columns
cols lays its children out in equal columns, however many there are. cols-2 and cols-3 fix the count.
<section class="cols">
<div class="party">
<span class="label">Billed to</span>
<div class="name">{{ customer.name }}</div>
<div class="muted lines">{{ customer.address }}</div>
</div>
<div class="party">
<span class="label">Shipped to</span>
<div class="name">{{ ship_to.name }}</div>
<div class="muted lines">{{ ship_to.address }}</div>
</div>
</section>lines keeps the line breaks in a value, which is what you want for addresses.
#Tables
table.items is for line items. table.data is a denser table for reports; add zebra for striped rows.
<table class="items">
<thead>
<tr><th>Item</th><th class="num">Qty</th><th class="num">Unit price</th><th class="num">Amount</th></tr>
</thead>
<tbody>
<tr data-each="item in items">
<td>
<div class="item-name">{{ item.name }}</div>
<div class="item-desc" data-if="item.description">{{ item.description }}</div>
</td>
<td class="num">{{ item.quantity }}</td>
<td class="num">{{ item.unit_price | money }}</td>
<td class="num">{{ item.quantity | times: item.unit_price | money }}</td>
</tr>
</tbody>
</table>Both tables do the two things that are hard to get right in print:
- The header row repeats at the top of every page the table runs onto.
- A row never splits across two pages.
Use num on cells and headers that hold numbers. It right-aligns them and lines the digits up.
#Totals
<div class="totals">
<div class="row sub"><span>Subtotal</span><span>{{ subtotal | money }}</span></div>
<div class="row sub"><span>Tax</span><span>{{ tax | money }}</span></div>
<div class="row grand accent"><span>Total</span><span>{{ total | money }}</span></div>
</div>The block sits on the right and stays together on one page. sub rows are muted, grand is the bold total with a rule above it, and accent colours the amount.
#Blocks
| Class | Use |
|---|---|
section | Space above a block. |
callout | A tinted box for notes or payment details. callout accent tints it with the accent colour. |
badge | A small pill. Variants: ok (green), warn (amber), bad (red). |
rule-accent | A short accent-coloured bar, for under a title. |
doc-foot | A muted footer line with a rule above it, at the end of the document. |
spread | Puts two children at opposite ends of a line. |
<div class="callout section">
<span class="label">Payment details</span>
<div class="lines">{{ payment.instructions }}</div>
</div>
<span class="badge ok" data-if="status == 'paid'">Paid</span>
<span class="badge bad" data-if="status == 'overdue'">Overdue</span>#Signatures
For documents that are printed and signed by hand.
<section class="signatures">
<div class="signature">
<div class="line"></div>
<div class="who">{{ customer.contact }}</div>
<div class="role">Accepted for {{ customer.name }} · Date</div>
</div>
<div class="signature">
<div class="line"></div>
<div class="who">{{ prepared_by }}</div>
<div class="role">For {{ company.name }} · Date</div>
</div>
</section>For fields a reader fills in or signs on screen, see forms and signatures.
#KPI tiles
For reports and statements.
<div class="kpis">
<div class="kpi" data-each="kpi in kpis">
<div class="value">{{ kpi.value }}</div>
<div class="caption">{{ kpi.label }}</div>
</div>
</div>#Page control
| Class | Effect |
|---|---|
page-break | Starts a new page before this element. |
keep | Keeps this element on one page instead of splitting it. |
page | A fixed canvas exactly one page in size. For certificates, covers and badges. |
totals, callout, signatures, cols, kpis and doc-foot already keep themselves together. Headings never end up stranded at the bottom of a page.
#Full-page layouts
Set the margin to 0 and build inside a page element. It is exactly the page's width and height, so you can position things absolutely. Use one page per sheet.
<div class="page cert">
<div class="frame"></div>
<h1 class="serif">{{ title }}</h1>
<p class="recipient">{{ recipient.name }}</p>
</div>.cert { padding: 24mm; text-align: center; }
.cert .frame { position: absolute; inset: 9mm; border: 1pt solid var(--accent); }The size is also available as var(--page-w) and var(--page-h).
#Utilities
| Classes | Effect |
|---|---|
muted, faint, accent | Text colour. |
small, large, strong | 8.5pt, 12pt, semi-bold. |
right, center, nowrap | Alignment and wrapping. |
serif, mono | Switch font for one element. |
mt-0 to mt-4, mb-0 to mb-4 | Margin top and bottom: 0, 6, 12, 20, 32pt. |
#CSS variables
Use these in your own CSS so it follows the template's settings.
| Variable | Value |
|---|---|
--accent | The accent colour from settings. |
--ink, --muted, --faint | Text colours, strongest to lightest. |
--line, --wash | Hairline border colour and light background tint. |
--ok, --warn, --bad | Status colours. Each has a -wash background variant. |
--font-body, --font-heading, --font-mono | Font stacks. |
--page-w, --page-h | Size of the printable area. |
#Your own CSS
Template css is added after the kit, so your rules win. Work in print units (pt, mm) and keep it small:
.amount-due { font-size: 20pt; font-weight: 700; letter-spacing: -0.02em; }
table.items td { padding-top: 6pt; padding-bottom: 6pt; }