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>
);
}<script setup lang="ts">
import { DocxEditor } from '@docx-editor.dev/vue';
import '@docx-editor.dev/core/styles/editor.css';
defineProps<{ bytes: Uint8Array }>();
</script>
<template>
<div class="docx-editor contract-workspace">
<DocxEditor.Root :document="bytes">
<DocxEditor.Toolbar />
<div :style="{ display: 'grid', gridTemplateColumns: '1fr 320px', height: '600px' }">
<DocxEditor.Viewport :style="{ minHeight: 0 }">
<DocxEditor.Content />
</DocxEditor.Viewport>
<aside class="contract-panel"><!-- Application panel --></aside>
</div>
</DocxEditor.Root>
</div>
</template>Place Toolbar or Menu anywhere inside Root, or omit them.
| Part | Requirement |
|---|---|
| Application wrapper | Carries .docx-editor and your theme class. |
DocxEditor.Viewport | Bounded height. Holds the document and accepts className and style. |
DocxEditor.Content | No application controls inside it. |
DocxEditor.Navigation | Direct viewport child, or a positioned sibling. |
DocxEditorReview | Review 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><DocxEditor.Viewport :style="{ height: '520px' }">
<DocxEditor.Navigation :find-shortcut="false" />
<DocxEditor.Content />
<DocxEditorReview />
</DocxEditor.Viewport>| Prop | Default |
|---|---|
defaultOpen, or open with onOpenChange | false |
defaultTab, or tab with onTabChange: headings, find, goto | headings |
paneWidth (pixels) | 280 |
toggle (Boolean or part props) | true |
searchHighlight: all, active, none | all |
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' }} />| Value | Behavior |
|---|---|
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
Viewportsupplies. 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
fontskeeps the editor instance, selection, undo history, and collaboration session. A newdocumentcreates another instance. reviewDisplayModesets 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.