Skip to content
Press.js Press.js Press.js Docs

Page

The root container for your document. Every Press.js document must have exactly one <Page> component.

import { Page } from "@press-js/react";
function Report() {
return (
<Page type="A4" orientation="portrait" margin="20mm">
<h1>Report Title</h1>
<p>Document content goes here.</p>
</Page>
);
}
PropTypeDefaultDescription
typestring"A4"Page size preset (see presets below)
orientation"portrait" | "landscape""portrait"Page orientation
widthstring | numberpreset-dependentExplicit page width, overrides type
heightstring | numberpreset-dependentExplicit page height, overrides type
marginstring | number | object"16mm"Page margin (see formats below)
PresetDimensionsPresetDimensions
A0841 × 1189 mmA1594 × 841 mm
A2420 × 594 mmA3297 × 420 mm
A4210 × 297 mmA5148 × 210 mm
A6105 × 148 mmA774 × 105 mm
A852 × 74 mmA937 × 52 mm
A1026 × 37 mm
B01000 × 1414 mmB1707 × 1000 mm
B2500 × 707 mmB3353 × 500 mm
B4250 × 353 mmB5176 × 250 mm
B6125 × 176 mmB788 × 125 mm
B862 × 88 mmB944 × 62 mm
B1031 × 44 mm
Letter8.5 × 11 inLegal8.5 × 14 in
Tabloid11 × 17 inLedger11 × 17 in
Executive7.25 × 10.5 in

Preset names are case-insensitive and ignore spaces, hyphens, and underscores. All of these resolve to A4: "A4", "a4", "a_4", "a-4".

When you set orientation: "landscape" with a named preset, the dimensions are swapped. For example, type="A4" orientation="landscape" produces a 297 × 210 mm page.

The <Page> component renders a <div> with data-press-page and optional sizing attributes. These data attributes are the Press.js-native way to define a page container — they work with any framework:

<div
data-press-page
data-press-page-type="A4"
data-press-page-orientation="portrait"
data-press-page-margin="20mm"
>
<h1>Report Title</h1>
<p>Document content goes here.</p>
</div>

Available data attributes:

AttributeExampleDescription
data-press-pageMarks the element as a Press.js page container
data-press-page-type"A4", "Letter"Page size preset
data-press-page-orientation"portrait", "landscape"Page orientation
data-press-page-width"210mm"Explicit page width
data-press-page-height"297mm"Explicit page height
data-press-page-margin"20mm"Margin for all sides
data-press-page-margin-top"30mm"Top margin override
data-press-page-margin-right"15mm"Right margin override
data-press-page-margin-bottom"30mm"Bottom margin override
data-press-page-margin-left"15mm"Left margin override
data-press-page-margin-x"15mm"Left + right margin shorthand
data-press-page-margin-y"20mm"Top + bottom margin shorthand

Set width and height explicitly instead of type:

<Page width="100mm" height="150mm" margin="10mm">
{/* custom-sized content */}
</Page>

Single value — applies to all four sides:

margin="20mm"
margin={20} // 20px
margin="0.5in"

Object form — per-side control:

margin={{ top: "20mm", bottom: "20mm", left: "15mm", right: "15mm" }}
margin={{ x: "15mm", y: "20mm" }} // x = left+right, y = top+bottom
margin={{ top: "30mm" }} // partial override, rest default to 16mm

The width, height, and margin props accept these formats:

FormatExampleDescription
"Nmm""210mm"Millimeters
"Nin""8.5in"Inches
"Ncm""3cm"Centimeters
"Npt""12pt"Points (1/72 of an inch)
N793Bare number = CSS pixels (96 DPI)