Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Media

DOCX Editor

Media

DOCX Editor React component for Tailwind CSS v4

CSV ViewerDOCX Viewer
Live props
Content
src
fileName
author
State
defaultReadOnly
defaultSuggesting
dirty
Behavior
defaultZoom
defaultSidebarOpen
defaultDarkPages
webFonts
locale
Appearance
variant
radius
highlightColor
activeHighlightColor
selectionColor
Layout
showToolbar
showFormatBar
showThumbnails
showStatusBar
showComments
showChanges
showDarkPages
showFind
showImport
showDownload
showPrint
showReadOnlyToggle
height640px
Code
import { DocxEditor } from "@/components/ui/docx-editor"

<DocxEditor />
  1. Home
  2. Components
  3. Media
  4. DOCX Editor
Pro

DOCX Editor React component for Tailwind CSS v4

v1.0.0·Added in 1.5.0

A React Word (.docx) editor with real pages, styles, tables, images, find and replace, comments and tracked changes, saved as .docx.

Click on a page to place the caret and type; drag, double-click (word) or triple-click (paragraph) to select, Shift+click to extend. Arrow keys move by the lines you see on the page; Tab inserts a tab and Escape moves focus to the toolbars. The formatting bar sets the paragraph style (each style previews in a card), the font (the document's own fonts first), the size (type it, or A- / A+, Shift+Ctrl / ⇧⌘ + < >), bold, italic, underline, strikethrough, superscript, subscript, text color, highlight, links (Ctrl / ⌘+K opens a bar: Enter applies, Escape cancels), alignment, lists, indent (Ctrl / ⌘ + [ ]), line and paragraph spacing, images (pick or drop one, then drag a corner to resize), tables (a 10 x 8 grid; inside a table a menu adds, deletes, merges and splits), page breaks (Ctrl / ⌘+Enter), borders and clear formatting. What does not fit folds into the ⋯ menu; on a phone the bar sits at the bottom, above the keyboard. Ctrl / ⌘+F finds (Enter / Shift+Enter step, 2 of 6), Shift+Ctrl / ⇧⌘+H replaces one or all. Select text and add a comment (Ctrl+Alt / ⌥⌘+M): cards sit beside the pages where they fit, in a panel otherwise, with replies, resolve and reopen; tracked changes have Accept and Reject. The mode menu switches Editing, Suggesting (your edits become tracked changes under author) and Viewing. Zoom with - and +, the zoom menu (fit width, fit page), Ctrl / ⌘ + scroll, pinch, or Ctrl / ⌘ + = / -. The sidebar lists live page thumbnails (Up / Down, Home / End). Save (Ctrl / ⌘+S, with onSave), download, print (Ctrl / ⌘+P) and open another .docx from the toolbar; opening one over unsaved edits asks first.

DOCX Editor is a Pro React component in the React media components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add docx-editor, together with Alert Dialog, Button, Color Picker, Dropdown Menu, Kbd and 6 more and the npm packages @eigenpal/docx-editor-core, prosemirror-state, prosemirror-view, prosemirror-model, prosemirror-history, prosemirror-tables, jszip and lucide-react.

Add to a project

Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add docx-editor

DOCX Editor is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans or unlock it free with an account

Usage

Import DocxEditor from @/components/ui/docx-editor.

import { useRef } from "react"
import { DocxEditor, type DocxEditorHandle } from "@/components/ui/docx-editor"

export function AgreementEditor() {
  const editor = useRef<DocxEditorHandle>(null)
  return (
    <DocxEditor
      ref={editor}
      src="/demo/northwind-supply-agreement.docx"
      author="Emma Carter"
      height="80dvh"
      onSave={async (blob, { fileName }) => {
        const body = new FormData()
        body.append("file", blob, fileName)
        await fetch("/api/documents", { method: "POST", body })
      }}
      onDirtyChange={(dirty) => console.log(dirty ? "Unsaved changes" : "Saved")}
    />
  )
}

Props

  • srcdefault "/demo/northwind-supply-agreement.docx"
    string

    URL of the .docx: same origin, a CORS-enabled URL or a blob: URL. Empty shows the open-a-document state. The playground value is the sample agreement.

  • fileNamedefault ""
    string

    Name for downloads, onSave and the document's accessible label. Falls back to the last part of src or the opened file's name.

  • authordefault "You"
    string

    The name on comments you add and on suggestions made in Suggesting mode; its initials sit in the status bar.

  • defaultReadOnlydefault false
    boolean

    Opens in view-only mode: no caret, no formatting bar; Download and Print still work. The mode menu can switch back. Use readOnly to control it.

  • defaultSuggestingdefault false
    boolean

    Opens in Suggesting mode: insertions and deletions become tracked changes by author. Use suggesting to control it.

  • dirtydefault false
    boolean

    Adds your own unsaved state to the status bar. Switching it from true to false after you stored ref.exportDocx() marks the content as saved.

  • defaultZoomdefault "automatic"
    number | "fit-page" | "fit-width" | "automatic"

    The zoom each document opens at: a scale (1 is 100%) or a fit mode. Automatic fits the width up to 100%, so a phone shows the whole page width.

  • defaultSidebarOpendefault true
    boolean

    Opens with the page thumbnails beside the pages. An editor narrower than 520px starts closed, since there the sidebar covers the page.

  • defaultDarkPagesdefault false
    boolean

    Opens with the pages inverted for reading at night; images keep their colors. Pages are white otherwise, in both themes.

  • webFontsdefault false
    boolean

    Loads metric-compatible fonts (Carlito for Calibri, Caladea for Cambria) from Google Fonts for closer line breaks. Off by default: no third-party requests.

  • localedefault "en-US"
    string

    Locale for the dates on comments and changes. Unset, it follows the UIProvider locale, then the browser's (en-US here).

  • variantdefault "surface"
    "surface" | "outline" | "plain"

    surface is a raised panel, outline a bordered box, plain has no frame for app panes that bring their own.

  • radiusdefault "md"
    "none" | "sm" | "md" | "lg"

    Corner radius of the frame: 0, 12, 16 or 24px.

  • highlightColordefault "rgba(250, 204, 21, 0.45)"
    string

    Fill of every find hit (--docx-editor-highlight). Keep it translucent so the text stays readable.

  • activeHighlightColordefault "rgba(249, 115, 22, 0.5)"
    string

    Fill of the current find hit and of text waiting for a new comment (--docx-editor-active-highlight).

  • selectionColordefault "rgba(59, 130, 246, 0.28)"
    string

    The text selection drawn on the page (--docx-editor-selection).

  • showToolbardefault true
    boolean

    The document toolbar: thumbnails, page, mode, zoom, find, view switches, save and the ⋯ menu.

  • showFormatBardefault true
    boolean

    The formatting bar. Hidden in view-only mode; below 600px of width it moves to the bottom, above the keyboard.

  • showThumbnailsdefault true
    boolean

    The page thumbnails sidebar and its toggle.

  • showStatusBardefault true
    boolean

    The bottom line with the page, the word count, the mode and the saved state.

  • showCommentsdefault true
    boolean

    Comment cards, Add comment and their switch.

  • showChangesdefault true
    boolean

    Tracked change cards with Accept / Reject, their switch and Suggesting in the mode menu.

  • showDarkPagesdefault true
    boolean

    The dark pages switch (in the ⋯ menu when narrow).

  • showFinddefault true
    boolean

    Find and replace, and Ctrl / ⌘+F inside the editor.

  • showImportdefault true
    boolean

    Open a document and New blank document in the ⋯ menu, and dropping a .docx onto the editor (not in view-only mode).

  • showDownloaddefault true
    boolean

    Download .docx with your edits (in the ⋯ menu when narrow).

  • showPrintdefault true
    boolean

    Print in the ⋯ menu and Ctrl / ⌘+P inside the editor.

  • showReadOnlyToggledefault true
    boolean

    Viewing in the mode menu, so people can switch to view-only themselves.

  • heightdefault 640
    number | string

    Height of the editor: px as a number, or any CSS length ("100%", "80dvh") to fill a pane.

  • file
    File | Blob | ArrayBuffer

    A document you already hold in memory; wins over src. A new object opens a new document.

  • readOnly
    boolean

    Controls view-only mode: no caret, no formatting bar, Download and Print still work. Pair it with onReadOnlyChange so the mode menu can switch it.

  • onReadOnlyChange
    (readOnly: boolean) => void

    Called when the mode menu or ref.setReadOnly switches view-only mode.

  • suggesting
    boolean

    Controls Suggesting mode. Pair it with onSuggestingChange so the mode menu can switch it.

  • onSuggestingChange
    (suggesting: boolean) => void

    Called when the mode menu switches Suggesting on or off.

  • zoomLevelsdefault "[0.5, 0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2]"
    number[]

    Steps of the zoom menu and the - / + buttons. The first and last are the zoom limits.

  • sidebarOpen
    boolean

    Controls the thumbnails sidebar. Inline from 520px of editor width, an overlay below it.

  • onSidebarOpenChange
    (open: boolean) => void

    Called when the sidebar opens or closes.

  • onDirtyChange
    (dirty: boolean) => void

    Called when the document gets unsaved edits, and again when they are saved or undone.

  • onChange
    (details: DocxEditorChangeDetails) => void

    Called 400 ms after the last edit, with the page count, word count and dirty flag. Get the file with ref.exportDocx().

  • onSave
    (blob: Blob, info: DocxEditorSaveInfo) => (void | Promise<unknown>)

    Shows a Save button and binds Ctrl / ⌘+S. Gets the .docx and its file name, page and word counts. Return a promise to show Saving and then Saved, or the error.

  • onDocumentLoadSuccess
    (document: DocxEditorDocument) => void

    Called when a document is ready, with its page and word counts, comments and tracked changes.

  • onDocumentLoadError
    (error: unknown) => void

    Called when a document cannot be fetched or parsed. The editor shows the error state with Try again.

  • onError
    (error: unknown) => void

    Called when an export, a save, an image or a layout pass fails.

  • onDocxUpload
    (file: File) => void

    Called with the File someone opened or dropped.

  • onActivePageChange
    (pageNumber: number) => void

    Called with the page in view as you scroll or jump.

  • onCommentAdd
    (comment: DocxEditorComment) => void

    Called when someone adds a comment or a reply.

  • onCommentResolve
    (comment: DocxEditorComment) => void

    Called when a comment is resolved.

  • onChangeAccept
    (change: DocxEditorChange) => void

    Called when a tracked change is accepted.

  • onChangeReject
    (change: DocxEditorChange) => void

    Called when a tracked change is rejected.

  • toolbarActions
    ReactNode

    Your own buttons at the end of the toolbar, before the ⋯ menu: share, send for signature, publish.

  • ref
    Ref<DocxEditorHandle> (a useRef object or an (handle) => void callback)

    exportDocx(), download(fileName?), getText(), insertText(text), focus(), undo(), redo(), scrollToPage(n), find(query), setReadOnly(readOnly), isDirty(), markSaved(), getPageCount() and getWordCount().

  • labels
    Partial<DocxEditorLabels>

    Every string, English by default (DEFAULT_DOCX_EDITOR_LABELS): toolbar and menu names, tooltips, find and replace, comments and changes, states, the discard dialog. Strings with numbers are functions, like findResults(active, total), wordCount(words) and tableSize(rows, columns).

  • classNames
    Partial<Record<"toolbar" | "formatBar" | "sidebar" | "thumbnail" | "viewport" | "page" | "annotation" | "statusBar" | "findBar" | "state", string>>

    Extra classes for the toolbar, the formatting bar, the sidebar, each thumbnail, the scrolling viewport, the pages, each card, the status bar, the find bar and the states.

  • className
    string

    Extra classes for the frame, merged last. Other div props are forwarded to it.

Parts

  • DocxEditorHandle

    type

    What the ref gets: exportDocx(): Promise<Blob>, download(fileName?), getText(), insertText(text), focus(), undo(), redo(), scrollToPage(pageNumber), find(query) (opens find and returns the count), setReadOnly(readOnly), isDirty(), markSaved(), getPageCount() and getWordCount().

  • DocxEditorDocument

    type

    What onDocumentLoadSuccess receives: pageCount, wordCount, comments (DocxEditorComment[]) and changes (DocxEditorChange[]).

  • DocxEditorComment

    type

    A comment or reply: id, author, initials, date, text, anchorText (the commented passage), parentId (for replies) and resolved.

  • DocxEditorChange

    type

    A tracked change: id (the revision), kind ("insertion" | "deletion" | "replacement" | "formatting" | "structure"), author, date, text and deletedText.

  • DocxEditorChangeDetails

    type

    What onChange receives: pageCount, wordCount and dirty.

  • DocxEditorSaveInfo

    type

    The second argument of onSave: fileName, pageCount and wordCount.

  • DocxEditorSource

    type

    What file accepts: File | Blob | ArrayBuffer.

  • DocxEditorZoom

    type

    A scale or "fit-page" | "fit-width" | "automatic".

  • DocxEditorMode

    type

    "editing" | "suggesting" | "viewing", the three modes of the mode menu.

  • DocxEditorLabels

    type

    The shape of labels: every string the editor renders.

  • DEFAULT_DOCX_EDITOR_LABELS

    constant

    The English labels. Spread it to translate a few strings.

Examples

Save with an unsaved indicator

onSave adds Save and Ctrl / ⌘+S; onDirtyChange drives the indicator above the editor.

Read-only, unlocked from outside

readOnly hides the formatting bar and the caret; Download and Print keep working.

Review: suggesting, comments, accept and reject

defaultSuggesting tracks edits as author; cards beside the pages accept, reject, reply and resolve.

Start from a blank page

Without src the editor offers to open a .docx or start a new blank document.

Your own toolbar actions, no sidebar

toolbarActions adds Share and Send for signature; showThumbnails={false} drops the sidebar.

Export to a Blob through the ref

ref.exportDocx() returns the edited .docx; its size, word and page counts show above.

On a phone

One-row toolbars, formatting at the bottom above the keyboard, fit-width pages and sheets for menus.

Dependencies

@eigenpal/docx-editor-coreprosemirror-stateprosemirror-viewprosemirror-modelprosemirror-historyprosemirror-tablesjsziplucide-reactalert-dialogbuttoncolor-pickerdropdown-menukbdpopoverselecttooltipuse-controllable-stateuse-media-queryui-config

Files

  • components/ui/docx-editor.tsx

FAQ

Is the React DOCX Editor component free?

The preview, props and docs are free; copying the source needs a Pro plan. See plans.

How do I install DOCX Editor?

Run npx wingo-ui@latest add docx-editor. It also adds the Wingo UI items it builds on (Alert Dialog, Button, Color Picker, Dropdown Menu, Kbd and 6 more) and the npm packages @eigenpal/docx-editor-core, prosemirror-state, prosemirror-view, prosemirror-model, prosemirror-history, prosemirror-tables, jszip and lucide-react. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/docx-editor.

How does DOCX Editor behave on phones?

What does not fit folds into the ⋯ menu; on a phone the bar sits at the bottom, above the keyboard.

See also

DOCX ViewerRich Text EditorPDF ViewerFile Upload

More React media components

File SystemImage compareImage GalleryStep PlayerQR CodeCarousel
All 17 React media components

Articles using this component

  • React DOCX Viewer: Real Pages, Comments, Tracked Changes

    Component guides · Oct 16, 2026 · 9 min read

New components by email

New posts, product news and occasional offers from Wingo UI. We count clicks to keep it relevant.

PreviousCSV ViewerNext DOCX Viewer
Pageof –
1 column
Loading document
Y