---
title: Documents
description: The standard components of json-render-docx.
---

Word components. A `Document` is the root and holds `Section` elements. See the [overview](/components) for how to read the tables.

## Document

The Word document. Must be the root element. Children must be Section components. Takes child elements.

<img src="/gallery/docx-Document.png" alt="Document rendered in LibreOffice" width="522" height="142" />

Document in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `title` | `string` | yes | File title shown in document properties. |
| `author` | `string` | yes |  |
| `language` | `string` | yes | BCP 47 tag such as "en-US", so Word checks spelling in it. |

```json
{
  "type": "Document",
  "props": {
    "title": "Project report",
    "author": "Jane Doe",
    "language": "en-US"
  },
  "children": []
}
```

## Section

A run of pages with one page setup. Most documents have one Section. Children are the page header and footer, then the content. Takes child elements.

<img src="/gallery/docx-Section.png" alt="Section rendered in LibreOffice" width="1578" height="954" />

Section in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `size` | `enum` | yes | Page size. Default A4. One of `A4`, `Letter`, `A3`, `A5`, `Legal`. |
| `orientation` | `enum` | yes | One of `portrait`, `landscape`. |
| `margin` | `number` | yes | Page margin in inches. Default 1. 0.25 to 3. |

```json
{
  "type": "Section",
  "props": {
    "size": "A4",
    "orientation": "portrait",
    "margin": 1
  },
  "children": []
}
```

## Header

Text repeated at the top of every page of the Section. Put it first in the Section. Has no children: use `"children": []`.

<img src="/gallery/docx-Header.png" alt="Header rendered in LibreOffice" width="662" height="281" />

Header in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `text` | `string` | no | At most 120 characters. |
| `align` | `enum` | yes | Default right. One of `left`, `center`, `right`, `justify`. |

```json
{
  "type": "Header",
  "props": {
    "text": "Project report",
    "align": "right"
  },
  "children": []
}
```

## Footer

Text and page numbers repeated at the bottom of every page of the Section. Has no children: use `"children": []`.

<img src="/gallery/docx-Footer.png" alt="Footer rendered in LibreOffice" width="662" height="281" />

Footer in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `text` | `string` | yes | At most 120 characters. |
| `pageNumbers` | `boolean` | yes | Add "Page X of Y" after the text. |
| `align` | `enum` | yes | Default center. One of `left`, `center`, `right`, `justify`. |

```json
{
  "type": "Footer",
  "props": {
    "text": "Confidential",
    "pageNumbers": true,
    "align": null
  },
  "children": []
}
```

## Title

The document title, once, at the top of the first page. Has no children: use `"children": []`.

<img src="/gallery/docx-Title.png" alt="Title rendered in LibreOffice" width="522" height="114" />

Title in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `text` | `string` | no | At most 120 characters. |
| `align` | `enum` | yes | One of `left`, `center`, `right`, `justify`. |

```json
{
  "type": "Title",
  "props": {
    "text": "Quarterly report",
    "align": null
  },
  "children": []
}
```

## Heading

A heading. Word lists headings in its navigation pane and in a TableOfContents. Has no children: use `"children": []`.

<img src="/gallery/docx-Heading.png" alt="Heading rendered in LibreOffice" width="522" height="166" />

Heading in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `text` | `string` | no | At most 120 characters. |
| `level` | `integer` | no | 1 is a chapter, 3 the smallest. 1 to 3. |

```json
{
  "type": "Heading",
  "props": {
    "text": "Results",
    "level": 1
  },
  "children": []
}
```

## Paragraph

A paragraph of body text. Has no children: use `"children": []`.

<img src="/gallery/docx-Paragraph.png" alt="Paragraph rendered in LibreOffice" width="522" height="120" />

Paragraph in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `text` | `string` | no | A line feed in the text starts a new line. At most 3000 characters. |
| `align` | `enum` | yes | One of `left`, `center`, `right`, `justify`. |
| `bold` | `boolean` | yes |  |
| `italic` | `boolean` | yes |  |
| `color` | `string` | yes |  |
| `fontSize` | `number` | yes | Points. Null uses the theme size. 8 to 28. |

```json
{
  "type": "Paragraph",
  "props": {
    "text": "Revenue grew in every quarter.",
    "align": null,
    "bold": null,
    "italic": null,
    "color": null,
    "fontSize": null
  },
  "children": []
}
```

## List

A bulleted or numbered list. Has no children: use `"children": []`.

<img src="/gallery/docx-List.png" alt="List rendered in LibreOffice" width="259" height="185" />

List in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `items` | `string[]` | no | 1 to 30 items, each at most 300 characters. |
| `ordered` | `boolean` | yes | Numbered instead of bulleted. |

```json
{
  "type": "List",
  "props": {
    "items": [
      "Faster checkout",
      "Better search"
    ],
    "ordered": false
  },
  "children": []
}
```

## Table

A native table with a header row that repeats on every page the table spans. Has no children: use `"children": []`.

<img src="/gallery/docx-Table.png" alt="Table rendered in LibreOffice" width="533" height="165" />

Table in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `columns` | `string[]` | no | Header labels, one per column. 1 to 6 items, each at most 40 characters. |
| `rows` | `string[][]` | no | One string per column in each row. 1 to 60 items, each at most 6 items, each at most 200 characters. |
| `striped` | `boolean` | yes | Shade every second row. |

```json
{
  "type": "Table",
  "props": {
    "columns": [
      "Team",
      "Owner"
    ],
    "rows": [
      [
        "Checkout",
        "Mira"
      ],
      [
        "Search",
        "Tomas"
      ]
    ],
    "striped": null
  },
  "children": []
}
```

## Image

A centered picture. Always give alt text. Has no children: use `"children": []`.

<img src="/gallery/docx-Image.png" alt="Image rendered in LibreOffice" width="353" height="213" />

Image in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `src` | `string` | no | An https URL or a data: URI. Local paths are not allowed. |
| `alt` | `string` | no | What the image shows, for screen readers. At most 200 characters. |
| `width` | `number` | yes | Inches. Default 5. 0.5 to 6.5. |

```json
{
  "type": "Image",
  "props": {
    "src": "https://picsum.photos/800/450?random=1",
    "alt": "A mountain lake",
    "width": 5
  },
  "children": []
}
```

## PageBreak

Starts the next element on a new page. Has no children: use `"children": []`.

<img src="/gallery/docx-PageBreak.png" alt="PageBreak rendered in LibreOffice" width="1360" height="954" />

PageBreak in LibreOffice 26.8.3.1.

This component has no props.

```json
{
  "type": "PageBreak",
  "props": {},
  "children": []
}
```

## TableOfContents

A table of contents built from the headings. Word fills in the page numbers when the file opens. Has no children: use `"children": []`.

<img src="/gallery/docx-TableOfContents.png" alt="TableOfContents rendered in LibreOffice" width="534" height="297" />

TableOfContents in LibreOffice 26.8.3.1.

| Prop | Type | Nullable | Description |
| --- | --- | --- | --- |
| `title` | `string` | yes | At most 60 characters. |
| `maxLevel` | `integer` | yes | Deepest heading level to list. Default 3. 1 to 3. |

```json
{
  "type": "TableOfContents",
  "props": {
    "title": "Contents",
    "maxLevel": 2
  },
  "children": []
}
```
