Thumbnail Plugin

The Thumbnail Plugin adds a classic sidebar view with small, clickable previews of each page. It helps users orient themselves within a document and navigate quickly.

To ensure optimal performance with large documents, the plugin implements virtualization. It only renders the thumbnail images currently visible in the sidebar, recycling DOM elements as the user scrolls.

This plugin supports multi-document layouts, maintaining independent thumbnail lists, scroll positions, and render queues for every open document.

Installation

This plugin depends on the Render plugin to generate the images.

npm install @embedpdf/plugin-thumbnail @embedpdf/plugin-render

Registration

Import ThumbnailPluginPackage and its dependencies.

import { createPluginRegistration } from '@embedpdf/core' // ... other imports import { RenderPluginPackage } from '@embedpdf/plugin-render/vue' import { ThumbnailPluginPackage } from '@embedpdf/plugin-thumbnail/vue' const plugins = [ // ... other essential plugins createPluginRegistration(DocumentManagerPluginPackage, { /* ... */ }), createPluginRegistration(ViewportPluginPackage), createPluginRegistration(RenderPluginPackage), // Required dependency // Register and configure the thumbnail plugin createPluginRegistration(ThumbnailPluginPackage, { width: 120, // Sets the width of thumbnail images }), ]

Usage

The plugin provides two main components: <ThumbnailsPane /> (the virtualized container) and <ThumbImg /> (the actual image renderer).

Building a Sidebar

You typically place <ThumbnailsPane /> in a sidebar container. It uses a scoped slot pattern: you provide a template that receives metadata (meta) for each visible item, and you return the markup for that thumbnail.

You must provide the documentId to both components to link them to the correct document state.

The meta Object

The meta object passed to your scoped slot contains calculated layout values. You must apply these styles for virtualization to work:

  • meta.top: Absolute vertical position. Apply to top.
  • meta.wrapperHeight: Total height of the item row. Apply to height.
  • meta.width / meta.height: Dimensions of the image itself.
<script setup lang="ts"> import { useScroll } from '@embedpdf/plugin-scroll/vue'; import { ThumbnailsPane, ThumbImg } from '@embedpdf/plugin-thumbnail/vue'; const props = defineProps<{ documentId: string }>(); const { provides: scroll } = useScroll(() => props.documentId); </script> <template> <div class="relative h-full overflow-hidden"> <ThumbnailsPane :document-id="documentId"> <template #default="{ meta }"> <div :key="meta.pageIndex" :style="{ position: 'absolute', top: `${meta.top}px`, height: `${meta.wrapperHeight}px`, width: '100%' }" @click="scroll?.scrollToPage({ pageNumber: meta.pageIndex + 1 })" > <div :style="{ width: `${meta.width}px`, height: `${meta.height}px` }"> <ThumbImg :document-id="documentId" :meta="meta" /> </div> <span>{{ meta.pageIndex + 1 }}</span> </div> </template> </ThumbnailsPane> </div> </template>

Live Example

This example shows a complete PDF viewer with a thumbnail sidebar. Notice how the sidebar automatically scrolls to track the current page in the main viewport.

API Reference

Configuration (ThumbnailPluginConfig)

OptionTypeDescription
widthnumberThe width of the thumbnail image in CSS pixels.
Default: 120
gapnumberThe vertical space between each thumbnail in CSS pixels.
Default: 8
buffernumberThe number of off-screen thumbnails to render above/below the viewport.
Default: 3
labelHeightnumberHeight reserved for the label below the image.
Default: 16
autoScrollbooleanIf true, the sidebar scrolls to keep the current page in view.
Default: true
paddingYnumberVertical padding for the thumbnail container.
Default: 0

Component: <ThumbnailsPane />

The virtualized scroll container.

PropTypeDescription
documentIdstring(Required) The ID of the document to display thumbnails for.

Default Scoped Slot Props

PropertyTypeDescription
metaThumbMetaMetadata object for the thumbnail, containing position, size, and page index.

Component: <ThumbImg />

Renders the rasterized image for a thumbnail.

PropTypeDescription
documentIdstring(Required) The ID of the document.
metaThumbMeta(Required) The metadata object from the ThumbnailsPane scoped slot.

Composable: useThumbnailCapability()

Access the plugin API.

ThumbnailCapability Methods

MethodDescription
forDocument(id)Returns a ThumbnailScope for the specified document ID.

ThumbnailScope Methods (Returned by forDocument)

MethodDescription
scrollToThumb(pageIndex)Manually scrolls the sidebar to show a specific thumbnail.
Last updated on December 5, 2025

Need Help?

Join our community for support, discussions, and to contribute to EmbedPDF's development.