Thumbnail plugin

The `thumbnail` plugin previews document pages as thumbnails. Clicking a particular thumbnail will jump to associate page.

Install

npm install '@react-pdf-viewer/thumbnail';
The `thumbnail` plugin is included in the default-layout plugin

Usage

1. Import the plugin and styles
import { thumbnailPlugin } from '@react-pdf-viewer/thumbnail';
// Import styles
import '@react-pdf-viewer/thumbnail/lib/styles/index.css';
2. Create the plugin instance
const thumbnailPluginInstance = thumbnailPlugin(props?: ThumbnailPluginProps);
The `thumbnailPlugin()` function takes a `ThumbnailPluginProps` parameter that consists of the following property:
(? denotes an optional property)
PropertyTypeDescriptionFrom
`renderCurrentPageLabel`?`RenderCurrentPageLabelProps => ReactElement`Render custom page label for each thumbnail. See this example2.10.0
`renderSpinner`?`() => React.ReactElement`Custom loading indicator that replaces the default `Spinner`. See this example3.0.0
`thumbnailWidth`?`number`The width of thumbnails. See this example3.3.1
The plugin instance `thumbnailPluginInstance` provides the following property:
PropertyTypeDescriptionFrom
`Cover``ReactElement`Shows the thumbnail of a particular page. See this example2.9.0
`Thumbnails``ReactElement`Previews all thumbnails2.0.0
3. Register the plugin
Register the `thumbnail` plugin instance, and use the `<Thumbnails />` component to display all thumbnails.
const { Thumbnails } = thumbnailPluginInstance;
<Viewer plugins={[thumbnailPluginInstance]} />;

See also

Changelog

v3.12.0
  • The `Cover` component adds new `width` property
v3.11.0
  • The `Thumbnails` component provides new property to display the thumbnails in the given direction
  • The thumbnails are updated to look identically to the pages when users change the viewmode
v3.8.0
  • The `Cover` component doesn't rotate the corresponding rotated page
v3.3.3
  • Automatically scroll to the thumbnail of the initial page when it's set
v3.3.1
  • Add new `thumbnailWidth` option
v3.2.0
  • The `renderThumbnailItem` property of the `Thumbnails` component adds new `onRotatePage` function to rotate a particular thumbnail
  • The thumbnails aren't rotated after rotating the document
v3.0.0
  • Add new `renderSpinner` property that can be used to replace the default `Spinner` component
  • Add new `renderThumbnailItem` property that is used to customize the thumbnail renderer
  • The `Cover` component uses the image instead of canvas tag
  • The `Cover` component position isn't correct
  • The thumbnails are stuck at loading spinner
v2.10.0
  • Add new `renderCurrentPageLabel` option to support custom page labels
  • Fix the TypeScript definition of the `Cover` component
v2.9.0
  • Add new `Cover` component that shows the thumbnail of a particular page
  • Show the page numbers for thumbnails
v2.5.0
  • There are big spaces between thumbnails
v2.4.3
  • Automatically scroll to the thumbnail that represents the current page
v2.0.0
  • First release