Customization

Layout

Arrange the DOCX editor toolbar, document, navigation, review, and application panels, and control zoom.

Compose editor parts inside your own grid or flex layout. DocxEditor.Root creates no wrapper element.

Arrange the editor

This grid puts an application panel beside the document. The shrinking viewport needs min-height: 0.

import { DocxEditor } from '@docx-editor.dev/react';
import '@docx-editor.dev/core/styles/editor.css';

export function ContractWorkspace({ bytes }: { bytes: Uint8Array }) {
  return (
    <div className="docx-editor contract-workspace">
      <DocxEditor.Root document={bytes}>
        <DocxEditor.Toolbar />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 320px', height: 600 }}>
          <DocxEditor.Viewport style={{ minHeight: 0 }}>
            <DocxEditor.Content />
          </DocxEditor.Viewport>
          <aside className="contract-panel">{/* Application panel */}</aside>
        </div>
      </DocxEditor.Root>
    </div>
  );
}

Place Toolbar or Menu anywhere inside Root, or omit them.

PartRequirement
Application wrapperCarries .docx-editor and your theme class.
DocxEditor.ViewportBounded height. Holds the document and accepts className and style.
DocxEditor.ContentNo application controls inside it.
DocxEditor.NavigationDirect viewport child, or a positioned sibling.
DocxEditorReviewReview module and an EigenPal Pro License.

Add navigation and review

Place DocxEditor.Navigation inside DocxEditor.Viewport. The pane stays in place while pages scroll.

<DocxEditor.Viewport style={{ height: 520 }}>
  <DocxEditor.Navigation findShortcut={false} />
  <DocxEditor.Content />
  <DocxEditorReview />
</DocxEditor.Viewport>
PropDefault
defaultOpen, or open with onOpenChangefalse
defaultTab, or tab with onTabChange: headings, find, gotoheadings
paneWidth (pixels)280
toggle (Boolean or part props)true
searchHighlight: all, active, noneall
findShortcut (Ctrl+F or Cmd+F)true
goToShortcut (Ctrl+G or Cmd+Option+G)true

Named parts are Toggle, Header, Title, Close, Tabs, Tab, Headings, Find, and GoTo. For a custom pane, use useNavigationPane, useDocumentOutline, useDocumentSearch, and useGoToBookmark. See Navigation.

For review pane overflow, see Tracked changes.

Control zoom

Set zoom and zoomMode on DocxEditor.Root.

<DocxEditor.Root document={bytes} zoomMode={{ type: 'fit', fit: 'pageWidth' }} />
ValueBehavior
zoom, such as 1 for 100%Fixed scale unless zoomMode says otherwise.
zoomMode: 'auto'Fits page width between 50% and 100%.
zoomMode: { type: 'fixed' }Keeps the scale when the viewport resizes.
zoomMode: { type: 'fit', fit: 'pageWidth' }Tracks available width, within minZoom and maxZoom.

Zoom never changes saved page dimensions or margins.

Limits

  • Keep the classes Viewport supplies. The editor finds its scroll container through them.
  • Do not replace the editor's pane spacing with fixed page offsets. Opening a pane changes the width a fit mode uses.
  • Changing fonts keeps the editor instance, selection, undo history, and collaboration session. A new document creates another instance.
  • reviewDisplayMode sets the initial revision view. Later prop changes do not update the existing instance.
  • fieldResults: 'editable' applies at construction, and collaboration refuses it. See Edit saved field results.
  • For prop lifetimes, see React composition or Vue composition.

See also