Sections
File Viewer
- Overview
- Anatomy
- Header
- Navigation
- Renderers
Use a controlled page rail when the document handle and current page are owned
outside the easy renderer API. PDF exposes this lower-level shape as
PdfThumbnailRail.
<PdfThumbnailRail
resource={resource}
currentPage={currentPage}
onSelectPage={scrollToPage}
thumbnailWidth={120}
thumbnailShape="page"
/>Behavior
- Fully controlled: you pass the
resource, the highlightedcurrentPage, and anonSelectPagehandler that jumps the document. The rail holds no page state of its own. - Pair it with a renderer's imperative handle — e.g.
PdfViewerHandle.scrollToPage— so clicking a thumbnail scrolls the surface to that page. - Prefer renderer-bound
FileViewerThumbnails
(
PdfViewerThumbnails) for normal compositions; reach for the controlled rail only when another workflow already owns page state.
API Reference
PdfThumbnailRail — the controlled rail:
| Prop | Type | Description |
|---|---|---|
resource | ViewerResource | Same resource object passed to the document renderer. Required. |
currentPage | number | null | 1-based page whose thumbnail is highlighted. |
onSelectPage | (page: number) => void | Fired with the 1-based page when a thumbnail is clicked. |
thumbnailWidth | number | Thumbnail image width in CSS px. The sidebar shell owns rail width. |
thumbnailShape | "page" | "square" | Preserve page aspect (page) or crop into a square frame. |
className | string | Optional class on the rail. |
Source
pdf-viewer-thumbnails.tsx
"use client";
import * as React from "react";
import { clearPdfDocumentResource } from "@/lib/pdf-document-resource";
import { cn } from "@/lib/utils";
import type { ViewerResource } from "@/lib/viewer-resource";
import { Spinner } from "@/components/ui/spinner";
import {
buildPdfThumbnailLayout,
PDF_THUMBNAIL_INITIAL_VIEWPORT_HEIGHT,