@forme/react.
Document
Root container for every Forme document. All other components must be descendants of<Document>.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | PDF metadata title |
author | string | - | PDF metadata author |
subject | string | - | PDF metadata subject |
creator | string | - | PDF metadata creator application |
Example
<Document>. If no <Page> children are provided, content uses the default page configuration (Letter size, 54pt margins).
Page
Defines a page boundary with explicit size and margin configuration. Content inside each<Page> is laid out independently.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "A4" | "Letter" | "Legal" | "A3" | "A5" | "Tabloid" | { width, height } | "Letter" | Page dimensions. Custom sizes are in points (72 points = 1 inch). |
margin | number | { top, right, bottom, left } | 54 | Page margins in points. A single number applies to all sides. |
Example
View
A flex container, analogous to an HTML<div>. Defaults to column layout.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
style | Style | - | CSS-like style properties |
wrap | boolean | true | Whether this container can break across pages. Set to false to keep all children on the same page. |
Example
flexDirection, justifyContent, alignItems, flexWrap, gap, flexGrow, flexShrink) are supported.
Text
Renders text content with font properties, colors, and alignment.Props
| Prop | Type | Default | Description |
|---|---|---|---|
style | Style | - | Typography and color styles |
children | string | number | - | Text content. Nested <Text> children are concatenated. |
Example
{{pageNumber}} and {{totalPages}} placeholders for dynamic page numbering.
Image
Embeds a JPEG or PNG image. Aspect ratio is preserved when only one dimension is specified.Props
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | (required) | Image source: base64 data URI (data:image/png;base64,...) or file path |
width | number | - | Display width in points |
height | number | - | Display height in points |
style | Style | - | Additional style properties (margin, etc.) |
Example
width is provided, height is calculated from the image’s aspect ratio (and vice versa). Both JPEG and PNG formats are supported, including PNG transparency.
Table
Table container with column definitions. Children should be<Row> elements.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns | ColumnDef[] | - | Column width definitions |
style | Style | - | Style properties for the table container |
Column width types
| Type | Example | Description |
|---|---|---|
{ fraction: number } | { fraction: 0.5 } | Proportional width (0.5 = 50% of table width) |
{ fixed: number } | { fixed: 100 } | Fixed width in points |
"auto" | "auto" | Size to content |
Example
header) are repeated at the top of each continuation page.
Row
A table row. Must be a direct child of<Table>.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
header | boolean | false | Whether this is a header row. Header rows repeat on every page when a table spans multiple pages. |
style | Style | - | Style properties (e.g., backgroundColor for alternating rows) |
Example
Cell
A table cell inside a<Row>.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
colSpan | number | 1 | Number of columns this cell spans |
rowSpan | number | 1 | Number of rows this cell spans |
style | Style | - | Style properties (padding, background, etc.) |
Example
Fixed
An element that repeats on every page as a header or footer. Reduces the available content area on each page.Props
| Prop | Type | Default | Description |
|---|---|---|---|
position | "header" | "footer" | (required) | Whether to place at the top or bottom of each page |
style | Style | - | Style properties |
Example
{{pageNumber}} and {{totalPages}} placeholders inside Fixed elements for automatic page numbering.