Presentation
Composable primitives for viewing and editing PowerPoint presentations in the browser.
Installation
pnpm dlx shadcn@latest add @diceui/presentation@diceui/pptx pulls in @diceui/pptx-core automatically. The thumbnail rail collapses below 768px behind a toggle, which is why this item also depends on button and use-mobile.
Layout
Import the parts, and compose them together.
import {
Presentation,
PresentationContent,
PresentationError,
PresentationLoading,
PresentationSelection,
PresentationSlide,
PresentationThumbnailList,
PresentationViewport,
} from "@/components/ui/presentation";
return (
<Presentation>
<PresentationThumbnailList />
<PresentationContent>
<PresentationLoading />
<PresentationError />
<PresentationViewport>
<PresentationSlide>
<PresentationSelection />
</PresentationSlide>
</PresentationViewport>
</PresentationContent>
</Presentation>
)Pass a File, Blob, ArrayBuffer, or Uint8Array to file on Presentation. There is no toolbar in this item — toolbars are assembled around the primitives.
Examples
Editing
Load with readOnly={false} and place PresentationSelection inside PresentationSlide to move, resize, and edit text. Undo and redo shortcuts are opt-in via undoRedoShortcuts. Drag thumbnails to reorder slides.
This example also uses PresentationZoomSelect, a companion control built with useZoom and select. Install it with @diceui/presentation-zoom-select.
API Reference
PresentationProvider
Makes an existing store available to descendants without rendering any DOM. Use it when a toolbar has to sit outside Presentation, or when the store is created with useCreatePresentationStore before the tree mounts.
Prop
Type
Presentation
The outermost component. Creates an internal store (or inherits one from PresentationProvider), loads the file, and provides context to all descendants.
Prop
Type
PresentationContent
Layout wrapper for the viewport column next to the thumbnail rail.
Prop
Type
PresentationViewport
Scrollable container that centers the slide and optionally auto-fits it to fill the available space. The styled wrapper defaults autoFit to true with 10px padding.
Prop
Type
PresentationSlide
Renders the active slide as a scaled DOM tree. Mounts an empty wrapper immediately so sibling layout is stable. Children are placed in an overlay; put PresentationSelection here.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-status] | "idle" | "loading" | "ready" | "error" |
PresentationSelection
PowerPoint-style editing overlay. Enables drag-to-move, resize, inline text editing, multi-select, and keyboard shortcuts. Renders nothing unless the presentation was loaded with readOnly={false}.
Must be placed inside PresentationSlide.
Prop
Type
| CSS Variable | Description | Default |
|---|---|---|
--presentation-selection | Accent color for the selection overlay, resize handles, and marquee. | var(--ring) |
PresentationLoading
Renders its children only while the presentation is in the "loading" state.
Prop
Type
PresentationError
Renders its children only when the presentation fails to parse.
Prop
Type
PresentationThumbnailList
Scrollable list of slide thumbnails. Below 768px the rail collapses behind a toggle button and closes on outside pointerup or Escape.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-mobile] | Present when the viewport is below 768px. |
PresentationThumbnailItem
Clickable item for a single slide in a PresentationThumbnailList.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-active] | Present when this item's slide is the active slide. |
PresentationThumbnailItemPreview
Renders the slide miniature for the enclosing PresentationThumbnailItem. Previews are rendered lazily as they approach the viewport.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-pending] | Present while the miniature has not been rendered yet. |
PresentationThumbnailItemNumber
Renders the 1-based slide number for the enclosing PresentationThumbnailItem.
Prop
Type
PresentationZoomSelect
Companion select for Fit and explicit zoom levels. Must be used inside PresentationProvider or Presentation.
Prop
Type
usePresentation
Subscribes to top-level presentation state: parse status, progress, and errors.
Prop
Type
useSlide
Subscribes to slide navigation state and exposes navigation actions.
Prop
Type
useZoom
Subscribes to zoom state. Setting an explicit level turns auto-fit off; setAutoFit(true) turns it back on.
Prop
Type
useHistory
Undo, redo, and whether the deck has unsaved edits.
Prop
Type
Create a store with useCreatePresentationStore for programmatic load, edit, save, and reset. See the store API for the full imperative surface.
Accessibility
Keyboard Interactions
Thumbnail list
| Key | Description |
|---|---|
| ArrowUpArrowDown | Moves focus and navigates to the previous or next slide. |
| Home | Moves focus to the first slide. |
| End | Moves focus to the last slide. |
| Escape | Closes the thumbnail rail on mobile. |
Selection overlay
Available when the presentation is loaded with readOnly={false}.
| Key | Description |
|---|---|
| Arrow Keys | Nudges the selection by 1px. Hold Shift for 10px. |
| DeleteBackspace | Deletes the selected shapes. |
| Escape | Exits text editing, then deselects. |
| Ctrl/Cmd + A | Selects every shape on the slide. |
| Ctrl/Cmd + Z | Undo. Bound only when undoRedoShortcuts is true. |
| Ctrl/Cmd + YCtrl/Cmd + Shift + Z | Redo. Bound only when undoRedoShortcuts is true. |