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.
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-viewerPro 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.
| Prop | Type | Notes |
|---|---|---|
title | string | — |
subtitle | string | Shown under the title — page count is appended automatically. |
pages | DocumentPage[] | — |
loading | boolean | Nothing to show yet. |
renderPage | (page: DocumentPage, size: { width: number; height: number }) => React.ReactNode | Render 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.ReactNode | Drawn over each page, in page coordinates. This is where an annotation layer, signature fields or highlights go. |
defaultPage | number | Start on this page. |
page | number | Controlled page. |
onPageChange | (page: number) => void | — |
defaultZoom | number | Start zoom, 1 = fit width. |
thumbnails | boolean | Show the thumbnail rail. Auto-hidden on narrow widths. |
height | number | "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. |
commenting | boolean | Commenting mode. Controlled, because the toolbar button and the overlay layer are two different components and only the caller sees both. |
onCommentingChange | (commenting: boolean) => void | — |
panel | React.ReactNode | The 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. |
panelOpen | boolean | Whether the panel is showing, for the toolbar toggle. |
onPanelOpenChange | (open: boolean) => void | — |
commentCount | number | Count shown on the panel toggle — open threads, not all threads. |
onDownload | () => void | — |
onClose | () => void | — |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themetooltipLifetime 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
Annotation Pins
PaidPins on the page and a searchable panel — one set of threads, two views.
Included with lifetime access
Signer Flow
PaidWho it is waiting on, how long, and what you can do about it.
Included with lifetime access
Document Request
PaidA checklist that counts approved, never uploaded.
Included with lifetime access