Skip to content

Component Props ​

For custom host sizing, see Viewport fitting for fitPadding, maxFitScale, framework-specific examples, and default values.

The PowerPointViewer component accepts the PowerPointViewerProps interface below. Only content is required; everything else is optional. This reference is taken directly from the source interface.

tsx
import { PowerPointViewer } from 'pptx-react-viewer';
import type { PowerPointViewerProps } from 'pptx-react-viewer';

TIP

PowerPointViewer uses forwardRef, so you can also pass a ref of type PowerPointViewerHandle - that is not part of PowerPointViewerProps.

Content ​

PropTypeDefaultDescription
contentUint8Array(required)Raw .pptx file bytes. Wrap an ArrayBuffer with new Uint8Array(buf).
filePathstring-Original file path or name. Used as the key for autosave recovery and display in the title bar.
fileNamestringgeneric labelDisplay name of the open document, shown in the title bar (for example quarterly-review.pptx).
autosavebooleantrueRecovery autosave. A policy ceiling over the title-bar toggle; see Autosave & Recovery.
autosaveIntervalMsnumberFile > Options cadenceRecovery cadence. An explicit value outranks the user's AutoRecover setting.
storageDocumentStoragenoneHost-owned storage: Save goes to storage.save(), recovery copies to its recovery methods. See Host-owned storage.
readOnlybooleanfalseMakes the deck read-only. true wins over canEdit; false only lifts this restriction.
fileProvidersreadonly CloudFileProvider[]-Cloud places for File > Open (for example OneDrive). A file opened from one saves back to that place instead of storage.

content type

The prop is a Uint8Array, not an ArrayBuffer. See Getting Started for conversion from a fetch/file ArrayBuffer.

Autosave recovery requires filePath

The viewer's built-in autosave serializes the document to IndexedDB keyed by filePath. On page reload, recovery detection checks for a recent snapshot matching the same filePath. If you don't persist and re-supply filePath across reloads, recovery won't trigger. See Autosave & Recovery below.

Editing ​

PropTypeDefaultDescription
canEditbooleanfalseEnables editing actions (toolbar editing controls, inspector edits, inline text editing, slide management). When false, the viewer is read-only.

Display ​

These match the Svelte and vanilla bindings; the defaults and clamping are shared.

PropTypeDefaultDescription
initialSlidenumber0Zero-based slide shown after each load, clamped into the deck. Changing it later applies to the next load, not the current slide.
googleFontsfalse | { baseUrl: string }unsetGoogle Fonts fallback for deck fonts that are neither installed nor embedded. Unset leaves it to File > Options > Trust Center > "Download fonts that are not installed or embedded" (on by default: loads them from fonts.googleapis.com); false sends no request to Google (text uses installed, embedded or fallback fonts) and locks that option off; { baseUrl } sends the CSS2 request to a self-hosted mirror instead and locks it on (an invalid baseUrl turns the fallback off and locks it off). See Fonts and privacy.
allowExternalContentbooleanunsetHost switch for content a deck links from another server (http(s) targets): pictures, picture fills and bullets, video, audio and poster frames. Unset follows PowerPoint: nothing is fetched when a deck opens, and a security bar offers Enable Content for that presentation (or the user's File > Options > Trust Center > "Allow external content", off by default, allows it always). false fetches none of it and shows no bar, true fetches it without asking; either value locks the Trust Center option to match. A change applies at once, without reloading the deck. Google Fonts requests are separate (googleFonts). See External content and privacy.
listConversionScope'paragraph' | 'list''paragraph'How far Bullets / Numbering reach from a bare caret. 'paragraph' converts only the caret's paragraph, as in PowerPoint. 'list' makes a caret that switches a list paragraph between bullets and numbering convert the whole list around it (adjacent items at its level and the deeper items nested between them), as in Word and Google Docs. Turning a list off, listing a plain paragraph and range selections are the same in both modes.
limitsPptxLoadLimitsunsetBounds on loading a deck, for hosts that show untrusted decks: maxInputBytes, maxUncompressedBytes, maxEntries, maxSlides, maxShapes. Unset keeps the core defaults (500 MiB inflated, 65,536 ZIP entries, nothing else bounded). A deck over a limit shows the load-error screen with the limit and the deck's value. A change applies from the next load. See Load limits.
showToolbarbooleantrueShow the editor chrome: title bar, ribbon and toolbar, protected-view and read-only banners, the mobile toolbar and the status bar. false leaves the canvas (and the thumbnail pane, if shown).
ribbonDisplay'always' | 'tabs' | 'fullScreen''always'PowerPoint's Ribbon Display Options: 'always' docks tabs and commands, 'tabs' shows the tab row and lays a tab's commands over the slide when it is chosen, 'fullScreen' hides the title bar and the ribbon behind a strip at the top. The user changes it from the menu at the right end of the tab row, with Ctrl+F1 or a double click on a tab; changing the value from the host switches the mode.
showThumbnailsbooleantrueShow the slide thumbnail pane. It still follows the user's own collapse toggle and the slidesPane customisation panel.
showCompatibilityToastsbooleantrueShow the compatibility warning toast stack after a load. false hides the stack only; the warnings are still collected. Independent of showToolbar.
tsx
<PowerPointViewer content={bytes} initialSlide={2} showToolbar={false} showThumbnails={false} />

Callbacks ​

PropTypeDefaultDescription
onDirtyChange(isDirty: boolean) => void-Called when the unsaved-changes flag flips.
onContentChange(content: Uint8Array) => void-Called with the re-serialized document bytes when content changes.
onActiveSlideChange(slideIndex: number) => void-Called when the active slide changes.
onModeChange(mode: ViewerMode) => void-Called when the viewer mode changes (e.g. edit to present).
onZoomChange(zoom: number) => void-Called when the zoom level changes.
onRibbonDisplayChange(mode: 'always' | 'tabs' | 'fullScreen') => void-Called when the user picks a Ribbon Display Options mode. Not fired when the host changes the value. The viewer keeps the choice for its own lifetime only; store it to bring it back on the next visit.
onSelectionChange(elementIds: string[]) => void-Called when element selection changes.
onSlideCountChange(count: number) => void-Called when the total slide count changes (slide added/deleted).
onChange() => void-Called after any committed document edit (move, resize, text, undo, redo, ...).
onAutosave(content: Uint8Array) => void-Called with the serialised deck each time a recovery autosave snapshot is written.
onAutosaveToggle(enabled: boolean) => void-Called when the user enables or disables autosave (title bar or File > Options).
onAutosaveStatus(status: 'idle' | 'saving' | 'saved' | 'error') => void-Called on every autosave lifecycle transition.
onAutosaveRecovery(record: AutosaveRecord) => void-Called when a recovery snapshot left by a previous session is found. The built-in recovery prompt is shown as well.
onPropertiesChange(updates: Partial<PptxCoreProperties>) => void-Called when the user (or the AI assistant) changes the document properties.
onNotesUpdate(notes: string) => void-Called with the new speaker-notes text after a notes edit.
onPresentationChange(presenting: boolean) => void-Called when presentation (slide show) mode is entered or left.
onCollaborationStatus(status: ConnectionStatus) => void-Called on every collaboration connection-status transition.
onOpenFile() => void-Host override for the File > Open action: bypasses the built-in file picker; the host then supplies a new content buffer instead.

INFO

onContentChange delivers a Uint8Array (the serialized document), not a boolean. To pull content on demand instead, use the handle's getContent().

Presentation / authoring ​

PropTypeDefaultDescription
authorNamestring-Display name used as the author for comments and annotations. Falls back to collaboration.userName when collaborating, otherwise 'You'.
classNamestring-Optional class name applied to the viewer root element.
smartArt3DbooleanfalseOpt in to the Three.js SmartArt renderer (extruded 3D blocks on WebGL). Requires the optional three peer; falls back to SVG without it.
surfaceChart3D, barChart3D, lineChart3D, areaChart3D, pieChart3DbooleanfalseIndependently opt in to interactive Three.js renderers for the matching 3D chart kinds. Each falls back to its SVG renderer when three is unavailable or the chart cannot be rendered as a WebGL scene.
aiPptxAiAssistant | PptxAiConfig-Enables the optional AI assistant: pass createAiAssistant(config) from pptx-react-viewer/ai, or a plain PptxAiConfig. Its SDK peers load only when the panel is opened; omit this prop to leave the assistant unavailable.

Theming ​

PropTypeDefaultDescription
themeViewerTheme-Theme configuration: partial color overrides, a custom radius, and arbitrary cssVars. Unset values fall back to the built-in dark theme. See Theming.
tsx
<PowerPointViewer
	content={bytes}
	theme={{
		colors: { primary: '#6366f1', background: '#0f172a' },
		radius: '0.75rem',
	}}
/>

Language ​

PropTypeDefaultDescription
defaultLocalestringstored choice, then 'en'Initial locale code for File > Options > Language. Falls back to a persisted localStorage choice, then 'en'. Ignored inside a PptxI18nProvider, whose locale is the language, and outside one when no react-i18next instance is configured (always so with pptx-react-viewer/no-i18next alone): the viewer then shows its built-in English text.
availableLocalesLocaleCatalogEntry[]registered react-i18next codesLocale choices offered by File > Options > Language. Defaults to the codes registered on the host's react-i18next instance. Inside a PptxI18nProvider there is no default: pass two or more, together with onLocaleChange, to show the Language category. No effect outside a provider when no react-i18next instance is configured (see defaultLocale).
onLocaleChange(code: string) => void-Called when the user picks a language from File > Options > Language. When provided, the host owns applying and persisting the choice; otherwise the viewer applies and persists it itself. Inside a PptxI18nProvider the host always owns the language: without this callback the Language category is left out. Outside a provider with no configured react-i18next instance (see defaultLocale) the category is left out and this is never called.

To translate the viewer with your own i18n library instead of react-i18next, wrap it in PptxI18nProvider (React only); see Use your own i18n library. To build without react-i18next, import from pptx-react-viewer/no-i18next; see Without react-i18next.

UI customization ​

PropTypeDefaultDescription
customizationViewerCustomization-Hide, lock or remap any part of the chrome: ribbon tabs and buttons, File > Options pages, sections and settings (lock a value, set a default), File tab pages and cards, context-menu entries, editor shortcuts, panels, features (AI, collaboration) and dialogs. Unioned with hiddenActions. A new object replaces the whole customisation.
tsx
<PowerPointViewer
	content={bytes}
	canEdit
	customization={{ ribbon: { hiddenTabs: ['draw'] }, disabledFeatures: ['ai'] }}
/>

The same helpers (hideRibbonTab, lockSetting, remapShortcut, ...) are available on the component ref to change it at runtime; see the API page. Every id, the rules and recipes are in the UI Customization guide.

Collaboration ​

These props enable and control real-time co-editing. See Collaboration for the full flow and the CollaborationConfig shape.

PropTypeDefaultDescription
collaborationCollaborationInput-When provided, enables collaborative editing with live cursors, presence, and Yjs CRDT sync. Takes the legacy CollaborationConfig or the shared CollaborationOptions (session, user, intent, provider, webrtc). Requires the yjs peer, plus y-websocket or y-webrtc for viewer-owned transports.
onStartCollaboration(config: CollaborationConfig) => void-Called when the user starts a session from the Share dialog. The host should set the collaboration prop with the returned config.
onStopCollaboration() => void-Called when the user stops a session from the Share dialog. The host should clear the collaboration prop.
onCollaborationChange(state: CollaborationState) => void-Reports the shared CollaborationState when a session starts or stops, and when its status, synced flag or people change.
shareDefaults{ roomId?: string; userName?: string; serverUrl?: string }-Default values for the Share dialog fields. If omitted, the fields start empty.

INFO

collaboration is controlled. The viewer does not start a session on its own - wire onStartCollaboration to set the collaboration prop, and onStopCollaboration to clear it.

Events, hooks and host extensions ​

PropTypeDescription
onLoad(detail: ViewerLoadDetail) => voidFired each time a presentation finishes loading without an error, with the slide count and canvas size.
onError(message: string) => voidFired once per distinct load failure, with a human-readable message.
onElementRenderError(error: Error, context: ElementRenderErrorContext) => voidA slide element was omitted because its renderer threw; context is { elementId, elementType, slideId }. Only that element is left out, on every surface. Defaults to console.error(error, context), also used when the callback throws. See Element render errors.
onHyperlinkClickHyperlinkClickHandlerFired before following a link; return false to cancel the default action.
ribbonAddInsreadonly RibbonAddInTab[]Ribbon tabs the host adds after Help. Each command runs its run callback and dispatches a bubbling office-ribbon-add-in event. Desktop ribbon only.
inspectorInitiallyOpenbooleanInitial inspector visibility; omitted keeps the desktop/mobile default.

Interface sketch ​

Abridged

This block shows the commonly used members, not the whole type. PowerPointViewerProps also carries ai, accountAuth, hiddenActions, fonts, availableThemes, defaultThemeKey, onThemeChange, onModeChange, onSelectionChange, onSlideCountChange and onZoomChange; the tables above cover fileName, onLoad, onError, onHyperlinkClick, ribbonAddIns, inspectorInitiallyOpen, defaultLocale, availableLocales and onLocaleChange. Read the shipped .d.ts (or packages/react/src/viewer/types-ui.ts) for the authoritative list.

ts
interface PowerPointViewerProps {
	content: Uint8Array;
	filePath?: string;
	fileName?: string;

	onDirtyChange?: (isDirty: boolean) => void;
	onContentChange?: (content: Uint8Array) => void;
	onActiveSlideChange?: (slideIndex: number) => void;
	onChange?: () => void;
	onAutosave?: (content: Uint8Array) => void;
	onAutosaveToggle?: (enabled: boolean) => void;
	onAutosaveStatus?: (status: 'idle' | 'saving' | 'saved' | 'error') => void;
	onAutosaveRecovery?: (record: AutosaveRecord) => void;
	onPropertiesChange?: (updates: Partial<PptxCoreProperties>) => void;
	onNotesUpdate?: (notes: string) => void;
	onPresentationChange?: (presenting: boolean) => void;
	onCollaborationStatus?: (status: ConnectionStatus) => void;
	onOpenFile?: () => void;
	onLoad?: (detail: ViewerLoadDetail) => void;
	onError?: (message: string) => void;
	onElementRenderError?: ElementRenderErrorHandler;
	onHyperlinkClick?: HyperlinkClickHandler;
	ribbonAddIns?: readonly RibbonAddInTab[];
	inspectorInitiallyOpen?: boolean;

	canEdit?: boolean;
	initialSlide?: number;
	googleFonts?: false | { baseUrl: string };
	allowExternalContent?: boolean;
	listConversionScope?: 'paragraph' | 'list';
	limits?: PptxLoadLimits;
	showToolbar?: boolean;
	ribbonDisplay?: 'always' | 'tabs' | 'fullScreen';
	showThumbnails?: boolean;
	showCompatibilityToasts?: boolean;
	className?: string;
	authorName?: string;
	smartArt3D?: boolean;
	surfaceChart3D?: boolean;
	barChart3D?: boolean;
	lineChart3D?: boolean;
	areaChart3D?: boolean;
	pieChart3D?: boolean;
	ai?: PptxAiConfig;

	theme?: ViewerTheme;

	collaboration?: CollaborationInput;
	onStartCollaboration?: (config: CollaborationConfig) => void;
	onStopCollaboration?: () => void;
	onCollaborationChange?: (state: CollaborationState) => void;
	shareDefaults?: {
		roomId?: string;
		userName?: string;
		serverUrl?: string;
	};
}

Notes on triggering features ​

Navigation, mode-switching, zoom, undo/redo, and selection are available through the imperative handle (ref.current.goNext(), ref.current.setMode('present'), etc.). Export and print are driven through the built-in toolbar/dialogs. See Export for details on document export.

Autosave & Recovery ​

When canEdit is true and a filePath is supplied, the viewer automatically saves recovery snapshots to IndexedDB while there are unsaved edits (by default one snapshot two minutes after the first unsaved edit). If the page is closed or crashes, the data persists in the browser.

How it works ​

  1. The first unsaved edit starts the interval (two minutes by default, see the cadence rule below). Later edits do not push it out, and nothing is written while the document is unchanged.
  2. When the interval ends, it serializes the current state to a Uint8Array and stores it in an IndexedDB database (pptx-viewer-autosave) keyed by filePath.
  3. On next load, if the viewer receives the same filePath and slides are loaded, it checks IndexedDB for a recent snapshot (within 24 hours) and opens the version-history panel.

Host responsibility ​

The viewer does not persist filePath across page reloads on its own. The host app must:

  1. Remember the file identifier (e.g. store it in localStorage, a URL parameter, or a backend session).
  2. Re-supply filePath when the viewer remounts after a reload.

Without this, the recovery check has no key to look up and will not find the saved snapshot.

Recovery helpers (shared package) ​

pptx-react-viewer does not re-export the autosave store. Its helpers come from ooxml-ui/pptx (a dependency of the package), which exports them for building custom recovery flows:

ts
import {
	getAutosaveSnapshot,
	listAutosaveSnapshots,
	deleteAutosaveSnapshot,
	saveAutosaveSnapshot,
} from 'ooxml-ui/pptx';

// List all stored snapshots (without the heavy data blob)
const snapshots = await listAutosaveSnapshots();
// => [{ key: 'report.pptx', timestamp: 1720300000000, size: 524288 }, ...]

// Retrieve a specific snapshot by its key (filePath)
const snapshot = await getAutosaveSnapshot('report.pptx');
if (snapshot) {
	// snapshot.data is a Uint8Array you can pass as `content`
	setContent(snapshot.data);
}

// Delete a snapshot (e.g. after the user dismisses recovery)
await deleteAutosaveSnapshot('report.pptx');

Reopening the deck after a refresh ​

Recovery snapshots answer "the tab crashed, can I get my edits back?". A plain refresh is the more common case, and it has its own helpers. rememberSessionDeck / restoreSessionDeck come from ooxml-ui/pptx (the React package does not re-export them; the other bindings do), and they remember the open deck per browser tab and hand it back on the next load:

ts
import { rememberSessionDeck, restoreSessionDeck } from 'ooxml-ui/pptx';

// After the host loads a deck:
await rememberSessionDeck(file.name, bytes);

// On mount, before falling back to your file picker:
const deck = await restoreSessionDeck();
if (deck) {
	setContent(deck.data);
	setFilePath(deck.fileName);
}
  • Scope is one browser tab. The record is keyed by an id held in sessionStorage, so a refresh reopens the deck while a brand-new tab still starts empty, and two tabs holding different decks never steal each other's content.
  • Edits are not lost. restoreSessionDeck() prefers a newer autosave snapshot of the same fileName, so a refresh mid-edit comes back with the edited deck rather than the bytes it was opened with.
  • The viewer's own File ▸ Open is covered. Opening a deck from the backstage (or from Recent) swaps it inside the viewer without notifying the host, so those paths record it themselves.
  • forgetSessionDeck() drops the record. Every call is best-effort: a blocked IndexedDB or a partitioned sessionStorage degrades to "nothing to restore", never to a thrown error.

All five demo apps use exactly this flow, which is why a refresh keeps the presentation on screen.

Example: recovery on page reload ​

tsx
import { getAutosaveSnapshot } from 'ooxml-ui/pptx';
import { PowerPointViewer } from 'pptx-react-viewer';
import { useEffect, useState } from 'react';

const STORAGE_KEY = 'my-app-last-file';

function App() {
	const [content, setContent] = useState<Uint8Array | null>(null);
	const [filePath, setFilePath] = useState('');

	// On mount, check for a recovery snapshot
	useEffect(() => {
		const lastFile = localStorage.getItem(STORAGE_KEY);
		if (!lastFile) return;

		getAutosaveSnapshot(lastFile).then((snapshot) => {
			if (snapshot && Date.now() - snapshot.timestamp < 24 * 60 * 60 * 1000) {
				// Offer recovery (or auto-restore)
				setContent(snapshot.data);
				setFilePath(snapshot.key);
			}
		});
	}, []);

	// When user opens a file, persist the name
	function handleOpen(file: File) {
		localStorage.setItem(STORAGE_KEY, file.name);
		setFilePath(file.name);
		file.arrayBuffer().then((buf) => setContent(new Uint8Array(buf)));
	}

	if (!content) return <FileDropzone onFile={handleOpen} />;

	return <PowerPointViewer content={content} filePath={filePath} canEdit />;
}

Who decides: the autosave prop or the AutoSave toggle? ​

Two things can speak about autosave, so one of them has to win. The rule is the same in all five bindings (react, vue, angular, svelte, vanilla) and lives in one shared decision function, resolveAutosaveActivation:

The autosave prop is a policy ceiling. The title-bar AutoSave toggle is the user's preference inside it.

autosave propWhat runsThe toggle
omittedAutosave runs; the user's toggle decides, defaulting to on.Works.
trueSame as omitted: the host permits it, the user decides.Works.
falseAutosave is off. No snapshots, and no recovery prompt on load.Inert (it must not move).

A host passing an explicit prop is stating what its application permits; a user flipping the switch is expressing a preference within that. A preference can never exceed a policy, which is why autosave={false} also takes the switch away: a control that silently does nothing is worse than no control. Two further gates are not negotiable by either party, because without them there is nothing to write or nowhere to write it: canEdit must be true, and filePath must be set.

The same rule governs the cadence. An explicit autosaveIntervalMs is a host policy and is honoured as given; omit it and the viewer follows the user's File > Options > Save > "Save AutoRecover information every N minutes" (two minutes by default).

The default is true because crash recovery that is off by default is crash recovery nobody has. Pass autosave={false} to opt out.

Recovering a snapshot ​

When a deck finishes loading and a snapshot newer than 24 hours exists for the same filePath, the viewer raises a "Recover unsaved changes?" dialog offering Restore or Discard. Restore loads the snapshot's bytes; Discard deletes it. The prompt is deliberately not raised for a snapshot this tab has already taken delivery of (for example when the host itself restored it through restoreSessionDeck).

Requirements and status feedback ​

Autosave automatically disables itself and displays a reason in the title bar when requirements are not met:

ConditionStatus shownReason
filePath not provided"AutoSave disabled: no file path provided"The viewer needs a stable key to store the snapshot under. Pass filePath to enable.
User toggles AutoSave off"AutoSave off"The user explicitly disabled it via the title-bar toggle.
autosave={false}"AutoSave turned off by this application"The host forbade it; the toggle is inert.
canEdit is false"AutoSave disabled: this presentation is read-only"Autosave is only relevant in edit mode.

When the missing requirement is resolved (e.g. filePath is set), the status automatically transitions back to 'idle' and the timer begins.

The AutosaveStatus type reflects this:

ts
type AutosaveStatus =
	| { state: 'idle' }
	| { state: 'disabled'; reason: string }
	| { state: 'saving' }
	| { state: 'saved'; timestamp: number }
	| { state: 'error'; message: string };

The reason field is one of 'autosave_host_off', 'autosave_toggle_off', 'no_file_path' or 'read_only', and maps through the shared autosaveDisabledReasonKey to the i18n keys pptx.autosave.disabledByHost, pptx.autosave.disabledToggleOff, pptx.autosave.disabledNoFilePath and pptx.autosave.disabledReadOnly respectively.

Released under the Apache-2.0 License.