ComponentsFoundations

Print button

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.

components/print-button.tsxtheme · material · accent · density · font

Installation

$ pnpm add @vamos-ui/react

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

PropTypeDefault
fileName
Suggested PDF name (the title is restored after the dialog).
string—
onBeforePrint / onAfterPrint
Expand collapsed sections before, clean up after.
() => void—
noHint
Drop the screen-reader description ("Opens the print dialog…").
boolean—
children
Label. All Button props pass through (variant defaults to secondary).
ReactNode"Print"
labels
Dictionary namespace "printButton": print, hint.
Partial<PrintButtonLabels>—

PrintStyles / printStyles(options)

PropTypeDefault
hide
Extra selectors to hide on paper.
string[]—
hideChrome
Hide nav, banner header, contentinfo footer, TopBar and Sidebar.
booleantrue
showUrls
Print external link addresses after the text; data-print-url="off" opts a link out.
booleantrue
margin / size
@page margin and size ("A4").
string"16mm" / printer
nonce
CSP nonce for the inline style (PrintStyles).
string—