Overview
A printed NDS page shows its own content and the site logo. The top bar, the navigation, the footer and the other site parts stay off the paper by themselves. Two attributes control the rest: data-print-target on a button prints one element alone, and data-hidden="print" keeps an element off the paper.
Pick another component when:
Markup
Vehicle Entry Permit
- Permit number
- VP-2026-04817
- Holder
- Mohammed Al-Harbi
- Plate
- ABC 1234
- Valid until
- 17/12/2026
Variants
| Group | Option | Markup | On element | Use |
|---|---|---|---|---|
| Structure | Print Target (default) | — | — | A button prints one element alone, such as a permit or a receipt. data-print-target names the element’s id |
| Structure | Hide on Paper | canon #print-hide |
— | An element that only works on screen, such as a Share button, stays off the paper |
Behavior
Print Target
A press on the button opens the browser’s print dialog with only the target on the paper. The rest of the page does not print, the site logo included. After the dialog closes, the page is as before. Ctrl+P still prints the whole page.
Target Layout
The target prints at its width on screen, in the middle of the sheet. A target wider than the sheet narrows to fit. A card or section around the target prints no frame, background or spacing.
Hide on Paper
data-hidden="print" hides the element on paper only. On screen it shows as usual. It adds to the other data-hidden tokens: data-hidden="sm print" hides the element on phones and on paper.
Built-in Features
-
Site Chrome Off the Paper
The top bar, the main navigation links and buttons, the breadcrumb, the side menu, the footer, the floating buttons, the cookie notice and the page feedback do not print. The site logo prints at the top.
-
Colors as on Screen
Colors, icons, checkmarks and colored bands print as they look on screen. By default a browser does not print background colors, and NDS paints its icons and checkmarks with one, so NDS tells the browser to print them.
-
White Paper
The page background does not print, so the sheet stays white around the content.
-
Light Print in Dark Mode
A page in dark mode, and every dark area on a page, prints in light colors, then returns to dark. A print target that has its own
data-theme="dark"keeps its dark look. -
No Script to Write
One click listener serves every
data-print-targetbutton. It starts only on a page that has one.
Best Practices
- Show the document on the page before the user prints it, as the sample above does. The user then sees what they will get.
- Set the paper size in your own stylesheet when the document needs one, such as
@page { size: A4; }. NDS sets no paper size. - Design the printed document yourself. NDS has no document layout, because each organization has its own.
- Put everything the document needs inside the target: logo, title, details, stamp. Nothing outside it prints.
- Give the print button a label that names the document, such as “Print permit”.
- Add
data-hidden="print"to controls inside a printed area that do nothing on paper, such as a Share or Copy button.
API
Data Attributes
| Attribute | Element | Effect |
|---|---|---|
data-print-target |
A button | Names the id of the element to print alone. A press opens the print dialog with only that element on the paper. A value that names no element does nothing, and the audit reports it |
data-hidden="print" |
Any element | Hides the element on paper only. It adds to the other data-hidden tokens |
data-nds-print-skip |
Every element outside the target | The script sets it before the print dialog opens, and removes it after the dialog closes. On paper the element is hidden. Do not write it yourself |
data-nds-print-self |
The target | The script sets it before the print dialog opens, with --nds-print-width: the target’s width on screen. It removes both after the dialog closes. On paper the target keeps that width, narrows to fit the sheet, and sits in its middle. Do not write it yourself |
data-nds-print-path |
Every parent of the target | The script sets it before the print dialog opens, and removes it after the dialog closes. On paper the parent has no background, border, shadow, padding or margin. Do not write it yourself |
JavaScript
| Method | Effect |
|---|---|
NDS.Print.init() |
Listens for clicks on every data-print-target button. The loader calls it on a page that has one. For a button added after the page loads, call NDS.init.mount() on its container |
NDS.Print.print(target) |
Prints one element alone, the same as the button. target is an element, an id or a selector. Returns false when it names no element |
Print fires no events. To print the whole page from your script, call the browser’s window.print().
The full API is in the banner of _js/nds-print.js. The print rules are in _sass/_utilities.scss.