Skip to main content
How text works in React DOCX and when to use each component.

The basics

Three ways to add text:

When to use what

Plain strings

For unstyled text. No wrapper needed:

Text component

When you need styling:

Formatting shortcuts

For common formatting without class names:

Mixing styles

Combine multiple styles in one paragraph:
Nest formatting shortcuts:
Add classes to shortcuts:

Text containers

These components can contain text: All work the same way:

Common patterns

Label + value

Status indicators

Highlighted text

Small print

Inline code

Superscript / subscript


Style inheritance

Styles flow from parent to child:
Child styles override parent styles:

Special characters

Line breaks

Tabs


Formatting reference


Anti-patterns

Unnecessary Text wrappers

Nested paragraphs