Hide or Show Sidebar Navigation in Our Viewer

PSPDFKit for Web includes contextual sidebars for page thumbnails, document outlines, bookmarks, and annotations. Each sidebar can be shown by pressing its corresponding toolbar button in a dropdownGroup called sidebar, which — by default — is located in the leftmost part of the main toolbar.

Launch Demo

These are the corresponding built-in toolbar button types for each sidebar button:


You can read more about built-in items and how to customize the toolbar in the Customize Existing Tools guide.

The sidebar can also be controlled programmatically by setting ViewState#sidebarMode with the Instance#setViewState API. For a list of all available modes, please refer to PSPDFKit.SidebarMode.

Using this API you can, for example, activate the annotations sidebar:

instance.setViewState((viewState) =>
	viewState.set('sidebarMode', PSPDFKit.SidebarMode.ANNOTATIONS),

Setting sidebarMode to null will hide the sidebar:

instance.setViewState(viewState => (
  viewState.set("sidebarMode", null);

The sidebar mode can also be set at load time when calling PSPDFKit.load() by specifying the corresponding value in the sidebarMode property of PSPDFKit.Configuration#initialViewState.

The following example activates the thumbnails sidebar when loading:

	initialViewState: new PSPDFKit.ViewState({
		sidebarMode: PSPDFKit.SidebarMode.THUMBNAILS,