Review colors and styling
Color tracked changes and comments by author or change type, add avatars, and style review chrome with CSS tokens.
Each author gets one color for tracked changes and comments. Authors take slots --doc-review-author-0 through --doc-review-author-7 in first-appearance order, and the palette repeats after eight authors.
For marks, named colors, change bar position, and cell shading, see Customize revision markup.
Set author styles
Mount AuthorStyle and ColorByChangeType declarations anywhere inside the editor root:
import { DocxEditor } from '@docx-editor.dev/react';
import { reviewModule } from '@docx-editor.dev/pro/react';
const MODULES = [reviewModule()];
<DocxEditor.Root document={bytes} modules={MODULES} author="Jess Lin">
<DocxEditor.AuthorStyle author="Jess Lin" color="#7c3aed" avatarUrl="/avatars/jess.png" />
<DocxEditor.ColorByChangeType />
<DocxEditor.Viewport>
<DocxEditor.Content />
</DocxEditor.Viewport>
</DocxEditor.Root>;<script setup lang="ts">
import {
DocxEditorAuthorStyle,
DocxEditorColorByChangeType,
DocxEditorContent,
DocxEditorRoot,
DocxEditorViewport,
} from '@docx-editor.dev/vue';
import { reviewModule } from '@docx-editor.dev/pro/vue';
defineProps<{ bytes: Uint8Array }>();
const modules = [reviewModule()];
</script>
<template>
<DocxEditorRoot :document="bytes" :modules="modules" author="Jess Lin">
<DocxEditorAuthorStyle author="Jess Lin" color="#7c3aed" avatar-url="/avatars/jess.png" />
<DocxEditorColorByChangeType />
<DocxEditorViewport>
<DocxEditorContent />
</DocxEditorViewport>
</DocxEditorRoot>
</template>AuthorStyle prop | Effect |
|---|---|
author | Exact w:author value to match. |
color | Document ink, decorations, and card accents. |
background | Background tint behind that author's changes. |
activeBackground | Highlight band of the open change. Removes its default underline. |
spanClassName / span-class-name | Classes on painted change spans. |
avatarUrl / avatar-url | Review card avatar. |
ColorByChangeType colors unmatched insertions green and deletions red. Author declarations take precedence for matched authors. Declarations render no DOM elements, and changing one repaints without resetting selection or undo history.
Update styles through the editor
Call setRevisionStyles with a RevisionStyles value. A headless host can pass revisionStyles when it creates the editor:
editor.setRevisionStyles({
others: 'kind', // 'author' (default) or 'kind'
authors: {
'Jess Lin': '#7c3aed',
'Sam Reyes': { color: '#0e7490', avatarUrl: '/avatars/sam.png' },
},
});Use declarations or setRevisionStyles as the single source of style state. A setRevisionStyles call replaces mounted declarations until a declaration changes.
Read authors and add avatars
useReviewAuthors() returns the document's authors for legends and color controls. Without an adapter, call getReviewAuthors(). React returns the list directly, and Vue returns a shallow ref.
| Field or behavior | Detail |
|---|---|
| Order | Tracked-change authors first, then comment-only authors. |
slot | Unbounded first-appearance rank. The CSS slot is slot % 8. |
color | Resolved card color, such as var(--doc-review-author-N). |
| Updates | After document load and style changes. |
useReviewAuthor returns one author's resolved color, slot, and declared style. In Vue, it accepts a ref or getter and returns a computed ref. Add .docx-editor to a legend or its ancestor so palette tokens resolve.
Set avatarUrl to replace initials on review cards. A rejected URL falls back to initials.
avatarUrl value | Result |
|---|---|
| Host URL | Accepted |
Application-held blob: URL | Accepted |
Non-SVG data:image/* URL | Accepted |
SVG data image or other data: URL | Rejected |
| Script scheme or protocol-relative host | Rejected |
The packaged image uses referrerPolicy="no-referrer". The editor never loads an avatar address from the document.
Customize CSS tokens
Override tokens under .docx-editor, and load your stylesheet after editor.css:
.docx-editor {
--doc-review-author-0: #7c3aed;
--doc-review-author-1: #0e7490;
--doc-revision-insertion-decoration-style: dashed;
--doc-revision-insertion-decoration-thickness: 0.08em;
}| Token | Use |
|---|---|
--doc-review-author-0 through --doc-review-author-7 | Author palette. |
--doc-revision-insertion, --doc-revision-deletion | Colors under ColorByChangeType. |
--doc-revision-insertion-decoration-style | Underline style, such as dotted. |
--doc-revision-insertion-decoration-thickness | Underline thickness. Default: 0.06em. |
--doc-revision-insertion-underline-offset | Underline distance. Default: 0.15em. |
--doc-revision-color-<name> | On-screen value of a named markup color. |
--doc-review-author-current | The element's author color on bands, cards, replies, balloons, and markers. |
Painted spans carry data-review-author. Bands, cards, replies, balloons, markers, and pilcrows also carry data-review-author-slot. Spans use inline ink, so a selector cannot override it. Use currentColor for metric-safe effects:
.docx-editor [data-review-author='Jess Lin'] {
outline: 1px dotted currentColor;
}Style the change bar
Change bars use separate tokens for All Markup and Simple Markup. They paint outside the dark-mode inversion, so define dark values too:
.docx-editor {
--doc-review-change-bar: #8a8a8a;
--doc-review-change-bar-width: 2px;
--doc-review-change-bar-simple: #d32f2f;
--doc-review-change-bar-simple-width: 3px;
}
.docx-editor.dark {
--doc-review-change-bar: #b0b0b0;
--doc-review-change-bar-simple: #ef5350;
}Each .docx-change-bar sits in one .docx-change-bars overlay per page. It carries docx-change-bar-insertion, docx-change-bar-deletion, or docx-change-bar-format, plus data-docx-story.
To color bars by kind, redefine --doc-review-change-bar on those classes. To hide them, set display: none on .docx-change-bars.
Export the same preferences
Pass the viewer state to the PDF exporter:
| Exporter option | Source |
|---|---|
revisionMarkup | editor.snapshot().revisionMarkup |
displayMode | editor.snapshot().reviewDisplayMode |
revisionAuthorSlots | The session's author color assignments. |
PDF output uses named print colors and the default author palette. Host CSS and revisionStyles colors do not apply. Pass revisionAuthorSlots to keep the session's color assignments after edits.
Limits
- Author matching uses the exact document name. It does not prove identity, because a sender can use any name.
- Keep span CSS metric-safe. Font size, weight, or family changes make painted text differ from measured layout.
--doc-review-author-currentholds the light-theme value in both themes. Add a dark rule when you tint by author.- Comment highlights use one yellow for all authors by default.