Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Flipbook

ProNew

Supplied page images or React content as a book: a two-page spread with a draggable 3D turn, thumbnails, page field, zoom and full screen. One page at a time on phones; PDF rasterization is up to the consumer.

Installation

pnpm dlx shadcn@latest add @viewport/flipbook

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
pages*FlipbookPage[]—
titlestring

Document name shown above the book and used to name it for screen readers.

—
aspectnumber

Page width divided by page height. 0.707 is A4 portrait.

0.707
heightnumber

Tallest the book may get, in pixels. It shrinks to fit narrow containers.

520
backgroundstring

Any CSS background for the stage behind the book.

"linear-gradient(135deg, #2952c8 0%, #2a86c4 55%, #2bb0ae 100%)"
defaultPagenumber

Page to open on, counted from 1.

1
toolbarboolean

Show the toolbar with zoom, thumbnails, page field and full screen.

true
maxZoomnumber

Largest zoom step. 1 turns zoom off.

2
singleBelownumber

Container width, in pixels, below which one page shows at a time.

600
loadingboolean

Shows a placeholder book while pages are being prepared.

false
onPageChange(page: number) => void

Called with the first visible page, counted from 1.

—
classNamestring—

Accessibility

  • The book is one focusable group: Left and Right or Page Up and Page Down turn the page, Home and End jump to the covers.
  • Toolbar buttons and the page field are named; the visible pages are announced politely after every turn.
  • Drag or tap the outer edge of a page to turn it; while zoomed the book scrolls instead.
  • The thumbnail panel takes focus when it opens, closes with Escape and returns focus to its button.
  • Under reduced motion edge dragging swaps pages on release without a rotating leaf; cancel leaves the page unchanged.