Print Guard

Print Guard is a copy-paste React component that stops printout doesn't match the screen before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/print-guard
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsPrintout doesn't match the screen

Was this component page useful?

How do I install Print Guard?

pnpm dlx shadcn@latest add @bollard/print-guard

The files land in your project. They're yours to edit.

How do I use Print Guard in React?

print-guard-usage.tsx
import { PrintGuard } from "@/components/ui/print-guard"

<PrintGuard target={doc} checkOnMount />

What input mistakes does Print Guard catch?

  • Light text on dark backgrounds the browser won't print
  • Collapsed sections that would print closed
  • Tables wider than the printable width
  • Scroll boxes that print only the visible part
  • Links printed without their address

What props does Print Guard accept?

PrintGuard props
PropTypeDefault
target

What gets printed. Defaults to the whole page.

React.RefObject<HTMLElement | null>—
pageWidth

Printable width in CSS px. Default: A4 with 1 cm margins (718). Letter is about 739.

numberA4_CONTENT_WIDTH
autoFix

Ctrl+P / Cmd+P can't be stopped, so apply every fix to those printouts too, then offer a review.

booleantrue
checkOnMount

Check as soon as it mounts and show what would be lost, without waiting for a click.

booleanfalse
describeIssue

Wording per issue; return `problem` and `fix`.

(issue: PrintIssue) => { problem: string; fix: string }describePrintIssue
printLabel

Print button content.

React.ReactNode"Print"
title

Panel heading.

string"This won't print the way it looks"
showLabel

Button text to show an affected element.

string"Show"
printFixedLabel

Button text to print with fixes.

string"Print with fixes"
printAsIsLabel

Button text to print without fixes.

string"Print as is"
cancelLabel

Cancel button text.

string"Cancel"
autoFixedText

`{count}` is filled in.

string"Fixed {count} for that printout."
reviewLabel

Button text to review an auto-fixed printout.

string"Review"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Print Guard accessible?

  • Toggle uses aria-expanded; the panel is a labelled region, inert when closed
  • Status uses role=status; focus moves into the panel and back to Print
  • Highlight motion is skipped under reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Default page width is A4 with 1 cm margins; set pageWidth for Letter or other sizes
  • Can't change the browser's own print settings (backgrounds, scale)
  • Checks the live DOM at print time; content loaded later is missed

What expensive mistakes does Print Guard stop?

Printout doesn't match the screen

Also known as

print · ctrl+p · print css · invoice print · pdf · receipt · print preview · @media print

What dependencies does Print Guard require?

Print Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePrint Guard
Registry identifier@bollard/print-guard
Install commandnpx shadcn@latest add @bollard/print-guard
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Print Guard

What form validation mistake does Print Guard catch?

Print Guard prevents printout doesn't match the screen. Before printing, finds what the paper will lose (dropped backgrounds, collapsed sections, cut-off tables) and fixes it for print only. Catches: Light text on dark backgrounds the browser won't print, Collapsed sections that would print closed, Tables wider than the printable width, Scroll boxes that print only the visible part, Links printed without their address. Limitation: validate print-guard schemas on backend.

How do I install print-guard with shadcn?

Run `npx shadcn@latest add @bollard/print-guard`. Sources added: registry/default/print-guard/print-guard.tsx, registry/default/print-guard/print-scan.ts. Package requirements: lucide-react.

What props customize Print Guard?

Print Guard accepts `target`, `pageWidth`, `autoFix`, `checkOnMount`, `describeIssue`. Configures print, ctrl+p, print css behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of print-guard?

Default page width is A4 with 1 cm margins; set pageWidth for Letter or other sizes. Can't change the browser's own print settings (backgrounds, scale). Checks the live DOM at print time; content loaded later is missed Server requirement: backend verification for print-guard.

How does Print Guard meet accessibility guidelines?

Toggle uses aria-expanded; the panel is a labelled region, inert when closed. Status uses role=status; focus moves into the panel and back to Print. Highlight motion is skipped under reduced motion. Minimizes errors: print preview broken, table cut off when printing.

Which components pair with Print Guard?