Docs / Print kit

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.

SettingDefaultValues
page_sizeA4A3, A4, A5, Letter, Legal, Tabloid
orientationportraitportrait, landscape
margin15mm 16mm 17mmOne to four CSS lengths (mm, cm, in, pt, px). Use 0 for full-bleed layouts.
fontinterinter (sans), source-serif (serif), jetbrains-mono (monospace), system
heading_fontsame as fontSame choices as font.
accent#111827A hex colour. Available in CSS as var(--accent).
page_numbersfalsetrue prints "1 / 3" at the bottom right of each page.
header_textText at the top left of each page. Up to 200 characters.
footer_textText 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>
ClassUse
doc-headThe header row.
brand, logo, brand-nameLogo image (scaled to fit) or the company name as text.
doc-id, doc-title, doc-numberRight-aligned title in the accent colour, with the document number under it.
metaA <dl> of label/value pairs. Add left to left-align it.
label, kickerSmall 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

ClassUse
sectionSpace above a block.
calloutA tinted box for notes or payment details. callout accent tints it with the accent colour.
badgeA small pill. Variants: ok (green), warn (amber), bad (red).
rule-accentA short accent-coloured bar, for under a title.
doc-footA muted footer line with a rule above it, at the end of the document.
spreadPuts 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

ClassEffect
page-breakStarts a new page before this element.
keepKeeps this element on one page instead of splitting it.
pageA 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

ClassesEffect
muted, faint, accentText colour.
small, large, strong8.5pt, 12pt, semi-bold.
right, center, nowrapAlignment and wrapping.
serif, monoSwitch font for one element.
mt-0 to mt-4, mb-0 to mb-4Margin top and bottom: 0, 6, 12, 20, 32pt.

#CSS variables

Use these in your own CSS so it follows the template's settings.

VariableValue
--accentThe accent colour from settings.
--ink, --muted, --faintText colours, strongest to lightest.
--line, --washHairline border colour and light background tint.
--ok, --warn, --badStatus colours. Each has a -wash background variant.
--font-body, --font-heading, --font-monoFont stacks.
--page-w, --page-hSize 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; }