Skip to main content
Root element for every document. Contains one or more sections.

Props


Theme per document

theme takes values in Tailwind’s theme.extend shape and adds them to the project’s tailwind.config. Use it when documents for different clients need different brand colors or fonts:
Colors must be hex (#0b5fff or #abc). Themes are per render, so documents rendered at the same time with different themes do not affect each other.

Metadata

Word shows these under File > Info, and document management systems read them. created and modified dates are written only when you pass them, so the same input always produces the same file.

Language

Word checks spelling and grammar in this language. Mark passages in another language with <Text lang="en-US">.

Custom properties

Word shows them in File > Properties > Custom, and document management systems can index them. Names starting with ReactDocx. are reserved for provenance.

Watermark

The same watermark Word’s Design > Watermark creates: people can change or remove it there. It is placed in every section’s header; sections without a header get one.

Base document and fonts

See Word templates and fonts.

Word settings

  • trackChanges turns on Review > Track Changes, including formatting changes, so edits made after generation are recorded.
  • updateFieldsOnOpen (default true) makes Word refresh the table of contents, page references and sequence numbers when the document opens. Word asks the reader to confirm. Set it to false if the prompt is unwanted; the fields then keep the values React DOCX computed until someone updates them.

Document styles

Configure default fonts and heading styles:

Font config

Heading config


Style inheritance

Text classes cascade to children (margins, padding, backgrounds and borders do not; see Inheritance):

Multiple sections

Each section can have different margins, page sizes, headers, and footers.