Skip to content
React PDF Viewer

Search

Custom toolbar

Replace the toolbar with your own controls, or combine parts of the built-in toolbar with buttons of your own.

Basics

renderToolbar(api) replaces the toolbar with anything you render, driven by the viewer API.

The custom toolbar sits where the built-in one would, honoring toolbar.position. It re-renders with a fresh api whenever page, zoom, rotation or status change.

Reusing the built-in toolbar

PdfToolbar is the built-in toolbar as a component. Render it with a subset of actions next to your own buttons.

PdfToolbar keeps its accessibility (single tab stop, arrow-key navigation, the responsive More actions menu) wherever you place it.

Customization

PdfToolbar takes config, labels, locale, compact, zoomReset, a replacement pageIndicator and menuPlacement.

Every prop is listed in the PdfToolbarProps reference; see also the customization guide.

Advanced / escape hatch

Hide the toolbar (toolbar={false}) and render controls anywhere in your layout with a ref, or build a viewer from scratch with the headless pieces.

Limitations

  • One toolbar slot. renderToolbar renders in the toolbar position only. Workaround: hide the toolbar and place controls anywhere with a ref.
  • PdfToolbar needs a viewer API. It cannot drive a headless PdfPageCanvas directly. Workaround: build headless controls from usePdfDocument state.

API

  • PdfToolbar — The default toolbar: zoom, page navigation, fullscreen, rotate, download and print, on one row.
  • PdfToolbarProps — Props for PdfToolbar: the viewer API it controls, its labels and configuration, the compact layout and the page indicator slot.