> ## Documentation Index
> Fetch the complete documentation index at: https://react-docx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Word templates and fonts

> Use the company's Word styles, theme and fonts in generated documents.

Documents that people correct in Word should behave like the company's own templates: the style gallery shows the company styles, headings use its colors, and the text shows in its fonts even where they are not installed.

***

## Base document

Point `base` at a `.dotx` or `.docx` made in Word:

```tsx theme={"dark"}
<Document base="templates/company.dotx">
  <Section>
    <H1>Inspection report</H1>
    <Paragraph styleName="Callout">Plant stopped from 8:00 to 14:00.</Paragraph>
  </Section>
</Document>
```

The generated document takes from the base:

* **Styles**, including the defaults (font, size, spacing) and Word's built-in styles as the company changed them
* **Theme** (colors and fonts that Word's theme choices refer to)
* **Font table and embedded fonts**
* **List numbering** definitions

The body, headers and footers of the base are not used; build the letterhead with components.

`base` takes a path, URL or bytes, and goes through the same [`loadFile`](/react-docx/getting-started/rendering) as images. It cannot be combined with the `styles` prop of `Document`.

### Headings and built-in styles

`H1` to `H6`, the table of contents, links and captions use Word's built-in styles. With a base, they use the base's version of each style, found by Word's internal name ("heading 1"). This works whatever language Word was in when the template was made: a Portuguese template calls it *Título 1* and the document still uses it.

Built-in styles the base lacks are added with the library's defaults.

### Styles by name

`styleName` applies a style from the base:

```tsx theme={"dark"}
<Paragraph styleName="Callout">…</Paragraph>
<Text styleName="Brand">ACME</Text>
<Table styleName="Company Table">…</Table>
```

The name can be the style's name as Word shows it, its id or one of its aliases, in any case. An unknown name fails the render with the list of styles of that type, so a typo does not silently produce unstyled text.

`className` still applies on top of the style, like inline formatting in Word.

A table style's header row formatting applies to tables with a [`Thead`](/react-docx/components/table). Word gives paragraph styles priority over table styles, so if the base's *Normal* style sets a text color, a table style's text color does not show; set the color in the table style's paragraph style or leave *Normal* without one.

***

## Embedded fonts

```tsx theme={"dark"}
<Document
  fonts={[
    {
      name: "Montserrat",
      regular: "fonts/Montserrat-Regular.ttf",
      bold: "fonts/Montserrat-Bold.ttf",
    },
  ]}
  className="font-['Montserrat']"
>
```

Each font lists its files per variant: `regular`, `bold`, `italic`, `boldItalic`. They are stored in the document, obfuscated as Word does, and Word uses them on machines without the font. `name` must be the family name the text uses.

* TrueType (`.ttf`) and OpenType (`.otf`) files are accepted. Prefer `.ttf`: Word may not use embedded fonts with PostScript (CFF) outlines
* Fonts whose license restricts embedding are refused with an error
* Each file adds its size to the document; embed only the variants in use

LibreOffice also reads embedded fonts. Readers that ignore them substitute a similar font.

***

## Language

```tsx theme={"dark"}
<Document lang="pt-BR">
  …
  <Text lang="en-US">safety data sheet</Text>
```

Word checks spelling and grammar in the document's language, and in the given language for passages marked with `lang`.
