Print or "Download PDF" for pages people keep on paper — a CV, an invoice, a recipe, a ticket. PrintButton opens the browser's print dialog and suggests a file name for Save as PDF; PrintStyles (or the printStyles() string) is a small print stylesheet that hides the site chrome, prints link addresses and keeps blocks together.
Weekly meal plan
Shopping list and recipes for five dinners. Source: example.com/plans/week-46
Printed from example.com
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { PrintButton, PrintStyles } from "@vamos-ui/react";
<PrintStyles />
<PrintButton fileName="cv-2026">Download PDF</PrintButton>Markup hooks: data-print="hide" (never on paper), data-print="only" (only on paper), data-print="keep" (no page break inside).
Print forces a light colour scheme and drops shadows and backdrop blur, so any theme prints as readable black on white.
Examples
The stylesheet
printStyles(options) returns plain CSS — inline it, or write it into your own stylesheet.
@media screen{
[data-print="only"]{
display:none!important}
}
@media print{
@page{
margin:14mm;size:A4}
html{
color-scheme:light}
[data-print="hide"],nav,header[role="banner"],body > header,footer[role="contentinfo"],body > footer,[data-slot="top-bar"],[data-slot="sidebar"],.cookie-banner{
display:none!important}
*,*::before,*::after{
box-shadow:none!important;text-shadow:none!important;backdrop-filter:none!important}
body{
background:transparent!important}
[data-print="keep"],figure,img,tr,pre,blockquote{
break-inside:avoid}
h1,h2,h3,h4{
break-after:avoid}
a[href^="http"]:not([data-print-url="off"])::after{
content:" (" attr(href) ")";font-size:.85em;word-break:break-all}
}
API
PrintButton
| Prop | Type | Default |
|---|---|---|
fileNameSuggested PDF name (the title is restored after the dialog). | string | — |
onBeforePrint / onAfterPrintExpand collapsed sections before, clean up after. | () => void | — |
noHintDrop the screen-reader description ("Opens the print dialog…"). | boolean | — |
childrenLabel. All Button props pass through (variant defaults to secondary). | ReactNode | "Print" |
labelsDictionary namespace "printButton": print, hint. | Partial<PrintButtonLabels> | — |
PrintStyles / printStyles(options)
| Prop | Type | Default |
|---|---|---|
hideExtra selectors to hide on paper. | string[] | — |
hideChromeHide nav, banner header, contentinfo footer, TopBar and Sidebar. | boolean | true |
showUrlsPrint external link addresses after the text; data-print-url="off" opts a link out. | boolean | true |
margin / size@page margin and size ("A4"). | string | "16mm" / printer |
nonceCSP nonce for the inline style (PrintStyles). | string | — |