Customization

Comments and review cards

Customize DOCX editor comment boxes and tracked change cards with named parts, card templates, and CSS state attributes.

Customize the cards in the review column with named DocxEditorReview parts. Review controls require the review module and an EigenPal Pro License.

Customize a review card

Pass a class to every card through card. Named parts replace packaged parts in place.

import { DocxEditor } from '@docx-editor.dev/react';
import { reviewModule, DocxEditorReview } from '@docx-editor.dev/pro/react';

const modules = [reviewModule()];

<DocxEditor.Root document={bytes} modules={modules}>
  <DocxEditor.Viewport style={{ height: 520 }}>
    <DocxEditor.Content />
    <DocxEditorReview card={{ className: 'contract-card' }}>
      <DocxEditorReview.Summary className="contract-comment-body" />
      <DocxEditorReview.Replies className="contract-thread" />
    </DocxEditorReview>
  </DocxEditor.Viewport>
</DocxEditor.Root>;

Style cards under your editor wrapper. Match presence attributes as [data-active], not [data-active="true"].

.docx-editor.contract-workspace .contract-card {
  border-radius: 12px;
  border-inline-start: 3px solid var(--doc-review-author-current);
  background: var(--doc-surface);
}
.docx-editor.contract-workspace .contract-card[data-active] {
  background: var(--doc-review-card-active-bg);
}

Formatting cards describe tracked highlight changes, such as Highlight: yellow. For custom cards, ReviewRevisionItem.formattingChanges includes highlight with the w:highlight color name, such as yellow.

Replace the card template

A React List render prop or a Vue #item slot takes over the card. Wrap it in Card so parts can read the item.

<DocxEditorReview>
  <DocxEditorReview.List>
    {(item) => (
      <DocxEditorReview.Card className="contract-card">
        <DocxEditorReview.Author />
        <p>{item.text}</p>
        <DocxEditorReview.Accept />
        <DocxEditorReview.Reject />
        <DocxEditorReview.Reply />
      </DocxEditorReview.Card>
    )}
  </DocxEditorReview.List>
</DocxEditorReview>

Inside the card, useReviewItem() reads the item and useReviewAuthor(item.author) returns its color and avatar. A template also replaces the compact resolved-comment view.

When the rail runs the template again

To keep scrolling and typing responsive, the rail runs the template for a card only when one of these values changes:

  • The item of the card.
  • In React, the function that you pass as the render prop.
  • In React, state from a hook that the render prop calls.
  • In Vue, reactive state that the slot reads.
  • In a Vue render function, the function that you pass as the #item slot or the default slot.

A template that reads any other value can show an old value. In React, such a value is a ref or a module variable that a function with a stable identity reads, for example a useCallback result. In Vue, such a value is a variable that is not reactive.

If the template reads a value that changes, use one of these options:

  • In React, pass a new function when the value changes, as an inline render prop does, or read the value with a hook inside your card component.
  • In Vue, keep the value in a ref or another reactive source, or read the value inside your card component.

A function that you create on each render is a new function each time. Examples are an inline React render prop and a slot function in a Vue render function. Each mounted card then runs the template once for each render of your component. The cards stay mounted and keep their state.

In a Vue template, the rail does not compare slot functions, so a render of your component runs no card template. The rail compares slot functions again in these cases: v-if or v-for selects the slot, or the slot reads a v-for or v-slot variable around it. Then each mounted card runs the template once for each render of your component.

The Vue rail needs Vue 3.4 or later to skip these renders.

Call hooks in a React render prop

A React render prop runs as the render of a component that belongs to the card, so it can call hooks. Call the same hooks in the same order on each run, as in any component.

An inline render prop calls the same hooks on each render, so its cards stay mounted and keep their state. If you switch between two render props that call different hooks, set a different key on DocxEditorReview for each one. The rail then mounts again, and each card starts from new state.

Configure cards and markers

DocxEditorReview propDefault and use
classNameStyles the review column.
card.classNameAdds a class to every card.
presettrue. false composes the column yourself.
stacktrue. false keeps cards at raw anchors.
gapPixels between cards. Use it instead of card margins.
filterChooses which items the column shows.
structuraltrue. Keeps structural decisions in the column.
formattingfalse. Formatting with page anchors uses balloons.
furnitureApplication content at the column start.
tResolves review labels.
PartUse
List, CardItem rendering and card wrapper.
Avatar, Author, Time, SummaryAuthor, metadata, and comment or change text.
Accept, Reject, Resolve, Reopen, DeleteDecisions and thread actions. Take icon.
Replies, Reply, Draft, AddComment, EmptyReplies, inputs, and empty state.
MarkersCollapsed markers. icon takes a node or an item callback.
BalloonBuilt-in balloon. Only className and hidden.

Parts accept className, hidden, asChild, and children where supported. The commentMarkers review pane setting picks initials or a comment icon for markers.

Cards expose data-kind (comment, custom item, or change kind), data-active, data-resolved, data-resolved-miniature, data-review-author, data-review-author-slot, and data-node-name (custom node type).

For card, comment, and author color tokens, see Review colors and styling.

Limits

  • filter never resolves items and gives no other route to a hidden decision.
  • For a comments-only column, set revisionsIn: 'balloons'. Changes then open in balloons at their text. See Tracked changes.
  • Keep the actions your workflow needs. Hide a part only when another route exists.
  • Show refused writes and unavailable actions. Keep reply focus while the user types, and the document selection when an action only opens controls.
  • Keep the column's geometry props in a Markers override.
  • With preset={false}, convert anchors with useReviewRailMetrics(). See Place custom cards.

See also