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 Viewer

Media

DOCX Viewer React component for Tailwind CSS v4

DOCX EditorExcel Viewer
Live props
Content
src
fileName
Behavior
defaultZoom
defaultCommentsVisible
defaultChangesVisible
defaultDarkPages
locale
Appearance
variant
radius
highlightColor
activeHighlightColor
commentHighlightColor
Layout
showToolbar
showThumbnails
defaultSidebarOpen
showSearch
showComments
showChanges
showDarkPages
showDownload
showUpload
height640px
Code
import { DocxViewer } from "@/components/ui/docx-viewer"

<DocxViewer />
  1. Home
  2. Components
  3. Media
  4. DOCX Viewer
Pro

DOCX Viewer React component for Tailwind CSS v4

v1.0.0·Added in 1.4.0

A React Word (.docx) viewer with real pages, headers and footers, thumbnails, zoom, search, comments, tracked changes and download.

Scroll through the pages: each one is laid out like Word's, with its header, footer and page numbers, and a page that runs long is split at its paragraphs and table rows. Type a page number in the toolbar (Enter jumps, Up and Down step, Escape cancels). Zoom with - and +, or pick Automatic, Fit page, Fit width or a percentage from the zoom menu. Search opens from the toolbar or with Ctrl+F / ⌘F while focus is inside the viewer: hits are highlighted, the counter reads 2 of 5, and Enter / Shift+Enter or the arrows step through them. Comments show as cards beside the pages with the commented text highlighted; click a card or the highlighted text to pick it. When the viewer is too narrow for the cards, markers sit on the page edge and open the card in a popover (a bottom sheet on phones). The toolbar switches comments, tracked changes (insertions underlined in green, removals struck through in red) and dark pages on or off and downloads the original file; below 720px of width these move into the ⋯ menu, which also opens another .docx (you can drop one onto the viewer too). Pinch with two fingers, or Ctrl / ⌘ + scroll, to zoom around that point. The sidebar shows page thumbnails: click to jump; in the list Up / Down move, Home / End jump. It starts open beside the pages; below 520px of width it starts closed, slides over the pages when opened and closes after a pick; below 440px the zoom steps move into the ⋯ menu.

DOCX Viewer 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-viewer, together with Button, Dropdown Menu, Popover, Tooltip, useControllableState and 1 more and the npm packages docx-preview 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-viewer

DOCX Viewer 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 DocxViewer from @/components/ui/docx-viewer.

import { DocxViewer } from "@/components/ui/docx-viewer"

export function ProposalPreview() {
  return (
    <DocxViewer
      src="/demo/project-proposal.docx"
      fileName="Riverside renovation proposal"
      height="80dvh"
      onDocumentLoadSuccess={({ numPages, outline }) => console.log(numPages, outline)}
    />
  )
}

Props

  • srcdefault "/demo/project-proposal.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 proposal.

  • fileNamedefault ""
    string

    Name used for downloads and in the document's accessible label. Falls back to the last part of src; an uploaded file keeps its own name.

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

    The zoom the document opens at: a scale (1 is 100%) or a fit mode. Automatic fits the width up to 100%, so a page never opens blown up on a large screen or cut off on a phone.

  • defaultCommentsVisibledefault true
    boolean

    Opens with the comments showing: cards beside the pages, or markers on the page edge in a narrow viewer.

  • defaultChangesVisibledefault false
    boolean

    Opens with tracked changes marked up (insertions underlined, removals struck through) and listed beside the pages. Off shows the document as it reads with every change accepted.

  • defaultDarkPagesdefault false
    boolean

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

  • 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.4)"
    string

    Fill of every search hit. Any CSS color; keep it translucent so the text stays readable. Also set as --docx-viewer-highlight on the frame.

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

    Fill of the current search hit and of the text behind the picked comment (--docx-viewer-active-highlight).

  • commentHighlightColordefault "rgba(250, 204, 21, 0.28)"
    string

    Fill of commented text while comments are showing (--docx-viewer-comment-highlight).

  • showToolbardefault true
    boolean

    The toolbar with page, zoom, search and file controls. Off leaves the bare pages, for previews you drive yourself.

  • showThumbnailsdefault true
    boolean

    The pages sidebar and its toggle.

  • defaultSidebarOpendefault true
    boolean

    Opens with the pages sidebar showing beside the pages. A viewer narrower than 520px (a phone) starts closed, since there the sidebar covers the page. Use sidebarOpen and onSidebarOpenChange to control it.

  • showSearchdefault true
    boolean

    The search button, and Ctrl+F / ⌘F inside the viewer.

  • showCommentsdefault true
    boolean

    Comments at all, and their switch in the toolbar (the ⋯ menu when narrow).

  • showChangesdefault true
    boolean

    The tracked changes switch in the toolbar (the ⋯ menu when narrow).

  • showDarkPagesdefault true
    boolean

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

  • showDownloaddefault true
    boolean

    The download button (in the ⋯ menu when narrow). It saves the original file.

  • showUploaddefault true
    boolean

    Open a document in the ⋯ menu and dropping a .docx onto the viewer. The file opens locally; onDocxUpload hands it to you.

  • heightdefault 640
    number | string

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

  • sidebarOpen
    boolean

    Controls the pages sidebar. Inline from 520px of viewer width, an overlay below it.

  • onSidebarOpenChange
    (open: boolean) => void

    Called when the sidebar opens or closes.

  • zoomLevelsdefault "[0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4]"
    number[]

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

  • toolbarActions
    ReactNode

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

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

    scrollToPage(page), scrollToHeading(id), scrollToAnnotation(id), getOutline() and getViewportElement().

  • renderPageOverlay
    (props: DocxViewerPageOverlayProps) => ReactNode

    Draws on top of every page: stamps, citations, signature fields. Gets the page number, its size at the current zoom and the scale, so boxes in percent always line up.

  • onActivePageChange
    (pageNumber: number) => void

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

  • onDocumentLoadSuccess
    (document: DocxViewerDocument) => void

    Called when a document is ready, with its page count, its outline (the headings, for a table of contents) and its comments and tracked changes.

  • onDocumentLoadError
    (error: unknown) => void

    Called when a document cannot be fetched or parsed. The viewer shows the error state.

  • onDocxUpload
    (file: File) => void

    Called with the File someone opened or dropped, after the viewer shows it.

  • onAnnotationClick
    (annotation: DocxViewerAnnotation) => void

    Called when a comment or change is picked, from its card, its marker or its text.

  • labels
    Partial<DocxViewerLabels>

    Every string, English by default (DEFAULT_DOCX_VIEWER_LABELS): page, of, pageNumber, pagesSidebar, pages, pageLabel(page), zoomIn, zoomOut, zoomLevel, fitPage, fitWidth, automatic, search, searchPlaceholder, searching, noResults, results(active, total), previousResult, nextResult, clearSearch, moreActions, comments, changes, darkPages, download, upload, document, loading, error, emptyTitle, emptyDescription, dropHere, annotations, comment, inserted, deleted, unknownAuthor, annotationLabel(kind, author).

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

    Extra classes for the toolbar, the sidebar, each thumbnail, the scrolling viewport, each comment card and the loading / empty / error states.

  • className
    string

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

Parts

  • DocxViewerHandle

    type

    What the ref gets: scrollToPage(pageNumber, options?), scrollToHeading(id, options?) with an id from the outline, scrollToAnnotation(id, options?), getOutline() and getViewportElement().

  • DocxViewerDocument

    type

    What onDocumentLoadSuccess receives: numPages, outline (DocxViewerHeading[]) and annotations (DocxViewerAnnotation[]).

  • DocxViewerHeading

    type

    An outline entry: id, title, level (1 for Heading 1) and pageNumber.

  • DocxViewerAnnotation

    type

    A comment or tracked change: id, kind ("comment" | "insertion" | "deletion"), author, initials, date, text, anchorText (the commented passage) and pageNumber.

  • DocxViewerPageOverlayProps

    type

    What renderPageOverlay receives: pageNumber, pageWidth and pageHeight at the current zoom, and scale.

  • DocxViewerZoom

    type

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

  • DocxViewerLabels

    type

    The shape of labels: every string the viewer renders.

  • DEFAULT_DOCX_VIEWER_LABELS

    constant

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

Examples

Comments and tracked changes

Comments and edits from the file sit beside the pages; onAnnotationClick reports the one you pick.

Outline and page tracking

onDocumentLoadSuccess hands over the headings, ref.scrollToHeading jumps to one and onActivePageChange follows the reader.

Sidebar closed

defaultSidebarOpen={false} starts with the pages only, at fit width; the toolbar button brings the thumbnails back.

Approve with your own actions

toolbarActions adds Share and Approve, and renderPageOverlay stamps the first page once it is approved.

On a phone

The sidebar slides over the page, comments become markers that open a bottom sheet and the toolbar stays on one row.

Dark pages

defaultDarkPages inverts the pages for night reading while images keep their colors.

Empty, open a file

Without src the viewer asks for a .docx: pick one or drop it onto the frame.

Dependencies

docx-previewlucide-reactbuttondropdown-menupopovertooltipuse-controllable-stateui-config

Files

  • components/ui/docx-viewer.tsx

FAQ

Is the React DOCX Viewer component free?

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

How do I install DOCX Viewer?

Run npx wingo-ui@latest add docx-viewer. It also adds the Wingo UI items it builds on (Button, Dropdown Menu, Popover, Tooltip, useControllableState and 1 more) and the npm packages docx-preview and lucide-react. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/docx-viewer.

How does DOCX Viewer behave on phones?

When the viewer is too narrow for the cards, markers sit on the page edge and open the card in a popover (a bottom sheet on phones).

See also

DOCX EditorPDF ViewerPowerPoint ViewerFile UploadFile manager

Used in

File System

More React media components

CSV ViewerImage compareImage GalleryStep PlayerQR CodeCarousel
All 17 React media components

Articles using this component

  • React PPTX Viewer: Slides, Notes and Presenter Mode

    Component guides · Nov 5, 2026 · 9 min read

  • React PDF Viewer: Search, Highlights, Real Annotations

    Component guides · Oct 19, 2026 · 9 min read

  • 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.

PreviousDOCX EditorNext Excel Viewer
Pageof –
Loading document