A printed page is a document, not a screenshot of the website. Every page on this site, including this one, prints as clean A4.
You're previewing another brand. This page documents Media Dreams' own brand, so its values, swatches and guidance are Media Dreams'. The live examples follow the brand you've chosen.
Try it: print this page or save it as a PDF. The navigation, buttons and switches disappear, the page turns light whatever theme you're using, and each sheet gets a footer with the page number.
Page setup
| Size | A4 (210 × 297 mm) |
| Margins | 16 mm top, 15 mm sides, 18 mm bottom |
| Running footer | "Media Dreams · mediadreams.co.uk" on the left, "Page n of N" on the right, in Plex Mono 8 pt |
| Source line | "Printed from" with the page address and date, at the top of page one |
| Body | IBM Plex Sans 11.4 pt on 1.5 line height; headings in Archivo, h1 at 25 pt |
Colour in print
Paper is always light: whatever theme the reader chose, a page prints on white in the light version of the brand it is showing, with that brand's typefaces, text, link and accent colours. Print the docs while previewing Gulo, Spotlight or a custom theme and the paper follows. Dark mode is never printed: it uses a lot of ink, and browsers that drop backgrounds would leave light text on white paper.
Five print tokens decide it. Four point at the brand's own light colours, so a new brand needs nothing extra; the rule colour is set per brand because screen borders are too faint for paper.
| Token | Light | Dark | Use |
|---|---|---|---|
#FFFFFFcolor.white | #FFFFFFcolor.white | The sheet, and any surface that would otherwise be tinted | |
#152238color.text.primary | #F3F0E9color.text.primary | Running text and headings on paper | |
#4B5567color.text.secondary | #B9C2D0color.text.secondary | Captions, labels and the source line | |
#C13D0Acolor.action.primary | #FF7A3Dcolor.action.primary | Links and accent marks on paper | |
#C3C9D2color.ink.200 | #C3C9D2color.ink.200 | Box outlines and dividers on paper: firmer than the screen border so they survive printing. Brands set their own. |
- Shadows and decorative fills are removed, and surfaces print white.
- Colour that carries meaning prints exactly: swatches, colour cards, spacing bars, code highlighting, logo dots and status lights are forced on, even when the browser's "background graphics" option is off.
- Live examples print as they look on screen, so a dark example is still dark on paper.
Layout rules
Most of these work from what a page looks like, not from class names, so a new site or component gets them without print rules of its own.
- Header: always the full header with the logo's strapline, even when the reader prints after scrolling, and never mid-animation.
- Chrome removed: navigation, buttons, forms, tab switches, video, dialogs, filters, sign-up boxes and social strips. Anything else that means nothing on paper takes
data-print="hide". - Words over pictures (a destination tile, a hero, a card title on a photo) print under the picture in the paper's ink, with the shading over the picture removed. Labels with their own background, such as a badge, stay where they are, and so does anything marked
data-print-overlay(a gallery's "+7 photos"). - Links: external links in running text print their address after the link text. A link around a picture or a whole card doesn't.
- Pagination: headings, and heading rows with a link or rating beside them, stay with what follows; cards, figures and tables don't split across pages, and a term in a list of facts stays with its value. A full-width band isn't kept whole, so it can't leave half a page empty.
- Grids of cards or pictures print as rows that can't split or overlap: two across, or up to four for short boxes such as stats and swatches.
data-print-cols="3"on a grid sets its own number;"0"leaves it alone. - Spacing: paper has its own scale, so screen spacing never leaks onto the page. Three gaps decide everything:
--print-gap-section(9 mm) before each section and above the footer,--print-gap-block(4 mm) between blocks such as a notice or a row of cards, and--print-gap-heading(2.5 mm) from a heading to what it introduces. Section padding, grid gaps, heading-row margins and the rules on full-width bands don't print. Containers whose parts sit side by side (a calendar, a row of buttons) keep their own spacing. - Boxes side by side are always the same height, and a row of them never splits across a page, in Chrome or Safari: each row prints as one unbreakable table row.
- Filtered lists say what was showing: give the filter area
data-print-filters="#results"(anddata-print-noun="yachts") and a filtered page prints "Showing 4 of 6 yachts, filtered by Guests: 8." in place of the controls. Somnia DS's article and case study indexes already do. - The footer prints as two short lines, one section gap below the page's last block.
- Safari lays the page out wider than Chrome when it prints (past the 900px breakpoint) and ignores
break-after: avoid. So a layout that changes at a narrow breakpoint needs its own print rule, and Somnia DS keeps each heading with what follows by wrapping them together, or by reserving room under the heading for the first part of a long block (the first row of months in a calendar). - Units with a grid of their own, such as calendar months, print in unbreakable rows like cards.
- Collapsed content such as FAQs prints open.
- Galleries print as they look on a wide screen, each picture filling its box; whole pictures (
fit="contain", such as a plan) print whole. Text for screen readers only ("open in the viewer") is left off. - A print button:
<PrintButton />(@somnia/core/components/PrintButton.astro) opens the print dialog, where readers can also save a PDF.labelchanges the wording (Headland's yacht pages: "Print or save Tamarind as a PDF"). It never prints itself. - Dark areas: a part of a page marked
data-theme="dark", or a band withclass="sn-inverse", prints light like the rest of the paper. Only example panes print dark.
Paper is 180 mm wide inside its margins, which is 680 px to the browser: a page prints in its phone or tablet layout. A component that should look different on paper (a portrait beside a biography rather than above it) needs a short @media print rule of its own.
Checking print
npm run print-check in a site's folder (core script somnia-print-check, run after a build) prints every page to A4 the way a reader does: part way down the page, with the browser's own print preparation, and with background graphics off, as browsers do by default. It fails when it finds:
- a logo that prints differently after scrolling;
- lines of text printed over each other, or words over a picture;
- text that can't be read on white paper, or a dark area;
- form fields, tabs or buttons on paper;
- a heading alone at the foot of a page;
- a linked picture printing a bare web address;
- a gap above the footer that isn't the section gap;
- boxes side by side that aren't the same height.
It warns about holes more than twice the section gap between two blocks.
Browsers add their own header and footer to printed pages (the date, the page title, the address and page numbers) unless the reader turns off "Headers and footers" in the print dialogue. A page can't switch them off without also losing its own running footer, so Somnia DS's pages are laid out to sit with them.
It also lists pages left more than 40% empty, and writes each page's PDF with a contact sheet of its printed pages to look over. Pull requests marked ready for review run it on each site they can change, printing only the pages that can print differently from before (scripts/changed-pages.mjs). It needs Playwright's browser (or CHROMIUM_PATH) and poppler (brew install poppler on a Mac).
Do
- Run the print check after changing a template, and look at the contact sheets
- Use
data-print="hide"for parts that mean nothing on paper - Mark colour that carries meaning (a booked day, a swatch)
print-color-adjust: exact
Don't
- Rely on colour or a hover state to carry meaning in print
- Add background fills that only make sense on screen
- Write print rules for one page when the fix belongs in a component or in Somnia DS
The thinking behind this is in the Insight article The ultimate print experience.