Composable primitives for viewing and editing PowerPoint presentations in the browser.
Installation
Install the main component and dependencies:
pnpm dlx shadcn@latest add "@diceui/presentation"Install the following optional components:
pnpm dlx shadcn@latest add "@diceui/presentation-zoom-select"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.
Without children, PresentationSelection renders its overlay parts with a default look. Compose them to restyle the overlay or leave parts out.
<PresentationSelection>
<PresentationSelectionBox>
<PresentationResizeHandle />
<PresentationRotateHandle />
</PresentationSelectionBox>
<PresentationSnapGuide />
<PresentationMarquee />
</PresentationSelection>Examples
Editing
Load with readOnly={false} to move, resize, rotate, and edit shapes and tables. The toolbar is built with useSelection and wrapped in PresentationControls, and the zoom control is @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.
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, rotation, snapping, inline text editing, multi-select, copy and paste, and keyboard shortcuts. Renders nothing unless the presentation was loaded with readOnly={false}.
Must be placed inside PresentationSlide.
| Action | Behavior |
|---|---|
| Click shape | Select |
| Click selected shape, double-click, or type | Edit text |
| Drag shape | Move (Shift locks one axis, Alt skips snapping) |
| Drag resize handle | Resize (Shift on a corner keeps the aspect ratio) |
| Drag rotate handle | Rotate (Shift steps by 15°) |
| Shift/Ctrl/Cmd + click | Toggle a shape in the selection |
| Drag empty canvas | Marquee select |
Moving and resizing snap to the slide's edges and center and to other shapes. Set snapping={false} to turn it off, or snapThreshold to change the distance. A text box left empty is removed once editing moves elsewhere.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-mode] | "idle" | "selected" | "move" | "resize" | "rotate" | "text" | "marquee" | "draw" |
| CSS Variable | Description | Default |
|---|---|---|
--presentation-selection | Color of the selection outline, handles, and marquee. | #1a73e8 |
--presentation-snap-guide | Color of the snap guides. | #f43f5e |
--presentation-snap-guide-width | Thickness of the snap guides. | 1px |
--presentation-rotate-handle-offset | Distance of the rotate handle above the outline. | 20px |
--presentation-rotate-cursor | Cursor over the rotate handle and while rotating. | crosshair |
PresentationSelectionBox
The outline around each selected shape. Rendered once per selected shape.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-presentation-selection-box] | Present on every outline. |
[data-mode] | "selected" | "move" | "resize" | "rotate" | "text" |
[data-dragging] | Present while the selection is being moved. |
[data-rotating] | Present while the selection is being rotated. |
PresentationResizeHandle
The handles on each edge and corner. Goes inside PresentationSelectionBox. On a shape too small to grab between them, they sit outside it, and a flat line shows only its two ends.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-presentation-resize-handle] | "nw" | "n" | "ne" | "e" | "se" | "s" | "sw" | "w" |
PresentationRotateHandle
The handle above the shape for rotating. Goes inside PresentationSelectionBox. Hidden while moving or resizing, and on tables and charts.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-presentation-rotate-handle] | Present on the handle. |
[data-rotating] | Present while the shape is being rotated. |
PresentationSnapGuide
The line shown when a shape snaps into place. Rendered once per snapped line while moving or resizing.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-presentation-snap-guide] | "x" | "y" |
PresentationMarquee
The box drawn while dragging across empty canvas, or while drawing with a draw tool.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-presentation-marquee] | Present on the marquee. |
[data-draw] | Present while drawing a text box or shape. |
PresentationControls
Wraps editor UI outside the slide, such as a toolbar. Pressing it keeps the selection and text editing, and so does pressing the popovers and menus it renders, even when they portal out. Must be used inside PresentationProvider or Presentation.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-presentation-controls] | Present on the wrapper. |
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, and at most 50 are kept in memory.
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
PresentationLayoutPreview
Renders a slide layout from getLayouts as a new slide would show it, with its placeholder prompts. The preview is rendered once it scrolls into view.
Prop
Type
| Data Attribute | Value |
|---|---|
[data-pending] | Present while the layout has not been rendered yet. |
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. Both undo and redo return a promise.
Prop
Type
useSelection
Reads the editing overlay's selection and its text formatting, and runs commands on it. Works anywhere under PresentationProvider or Presentation, so a toolbar can sit outside the slide.
Pressing a toolbar would normally clear the selection and end text editing. Wrap the toolbar in PresentationControls to keep them. Popovers and menus it renders count too, even when they portal out.
import { useSelection } from "@diceui/pptx";
import { PresentationControls } from "@/components/ui/presentation";
function FormattingToolbar() {
const { textStyle, setTextStyle } = useSelection();
return (
<PresentationControls>
<button
aria-pressed={textStyle?.bold ?? false}
disabled={!textStyle}
onClick={() => void setTextStyle({ bold: !textStyle?.bold })}
>
Bold
</button>
</PresentationControls>
);
}For UI that PresentationControls can't wrap, such as a context menu around the slide, put data-presentation-controls on the element itself (exported as CONTROLS_ATTRIBUTE).
Use anchor to position a floating toolbar over the selection, and show it while mode is "selected" or "text".
Tables use insertTable, changeTable, and setTableCellStyle, with cell and cellRange for the edited and selected cells.
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}. Screen readers announce what is selected.
| Key | Description |
|---|---|
| EnterF2 | Starts editing the selected shape's text. Typing also starts editing. |
| TabShift + Tab | Selects the next or previous shape. |
| Arrow Keys | Nudges the selection by 1px. Hold Shift for 10px. |
| DeleteBackspace | Deletes the selected shapes. |
| Escape | Disarms the draw tool, then exits text editing, then deselects. |
| Ctrl/Cmd + A | Selects every shape on the slide. |
| Ctrl/Cmd + D | Duplicates the selected shapes. |
| Ctrl/Cmd + CCtrl/Cmd + XCtrl/Cmd + V | Copies, cuts, or pastes shapes. Pasting an image inserts it. |
| Ctrl/Cmd + ]Ctrl/Cmd + [ | Brings the selection forward or sends it backward. Hold Shift to move it to the front or back. |
| Ctrl/Cmd + Z | Undo. Bound only when undoRedoShortcuts is true. |
| Ctrl/Cmd + YCtrl/Cmd + Shift + Z | Redo. Bound only when undoRedoShortcuts is true. |
Table cells
Pressing a cell edits it, and dragging across cells or Shift-clicking selects them.
| Key | Description |
|---|---|
| TabShift + Tab | Moves to the next or previous cell. Tab on the last cell adds a row. |
| Arrow Keys | At the edge of a cell's text, moves to the next cell. |
| Ctrl/Cmd + A | With cells selected, selects the whole table. |
| DeleteBackspace | Clears the selected cells. |
| Ctrl/Cmd + CCtrl/Cmd + XCtrl/Cmd + V | Copies, cuts, or pastes cells, including from spreadsheets. |