Launch price: lifetime access for $149, $199 after

Document Viewer

Page chrome for a document: a thumbnail rail, paging, zoom, and a layer for whatever has to sit on top of the page. It renders nothing itself — you pass a renderPage function, so you bring pdf.js, an image server or your own canvas.

DocumentsPro · Lifetime access780 lines · one file

The decision inside it

It does not bundle a PDF engine

Shipping one would add megabytes and pick your rendering strategy for you. The viewer takes a function and gets out of the way.

Installation

How you get it

One command. The CLI writes the file into components/ui/ and installs what it needs.

npx shadcn@latest add https://layropro.com/r/document-viewer

Pro components need the CLI token from your account page. Put it in your environment as LAYRO_KEY and use the namespaced form.

API

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
titlestring—
subtitlestringShown under the title — page count is appended automatically.
pagesDocumentPage[]—
loadingbooleanNothing to show yet.
renderPage(page: DocumentPage, size: { width: number; height: number }) => React.ReactNodeRender one page yourself. Return any node — a canvas driven by pdf.js, an img, an iframe. It is given the box it must fill.
overlay(page: DocumentPage, size: { width: number; height: number }) => React.ReactNodeDrawn over each page, in page coordinates. This is where an annotation layer, signature fields or highlights go.
defaultPagenumberStart on this page.
pagenumberControlled page.
onPageChange(page: number) => void—
defaultZoomnumberStart zoom, 1 = fit width.
thumbnailsbooleanShow the thumbnail rail. Auto-hidden on narrow widths.
heightnumber | "auto"How tall the viewer is, in pixels. It needs one. Left to grow with its content, a four-page document renders as four full-size pages down the host page and the scroller, the paging controls and the thumbnail rail all become decorative — which is exactly what it did before this prop existed. Pass a number, or `"auto"` to opt into the tall behaviour deliberately.
commentingbooleanCommenting mode. Controlled, because the toolbar button and the overlay layer are two different components and only the caller sees both.
onCommentingChange(commenting: boolean) => void—
panelReact.ReactNodeThe comments side panel, rendered to the right of the pages. The pin and the panel are not alternatives. A pin answers "what is wrong with this, here"; the panel answers "what is still open anywhere in this document". Pass `<CommentPanel/>` and the viewer makes room for it.
panelOpenbooleanWhether the panel is showing, for the toolbar toggle.
onPanelOpenChange(open: boolean) => void—
commentCountnumberCount shown on the panel toggle — open threads, not all threads.
onDownload() => void—
onClose() => void—

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Layro foundations, installed alongside it

layro-themetooltip

Lifetime access

Every component, and everything we ship next.

  • All 65 components, source included
  • The template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.

More in Documents