Skip to content
RPMoreOptions Beta

The RPMoreOptions displays the default menu items in the more options dropdown, allowing customization of icons, hiding/showing menu items, and adding custom menu items.

Mobile view behavior, when the PDF viewer is displayed in mobile view (container width below the breakpoint), tools such as openFileTool, downloadTool, printTool, and fullscreenTool are automatically grouped under the RPMoreOptions tool to optimize the mobile interface and save space in the toolbar. see Mobile View for more information.

NameTypeDescription
iconsRPMoreOptionsIconsChange the icons for each menu item
slotsRPMoreOptionsSlotsShow or hide specific menu items
slotTopReact.ReactNodeAdd custom menu items at the top of the dropdown
slotBottomReact.ReactNodeAdd custom menu items at the bottom of the dropdown
NameTypeDescription
openFileIconReact.ReactNodeTo change the icon of the open file button
downloadIconReact.ReactNodeTo change the icon of the download button
printIconReact.ReactNodeTo change the icon of the print button
fullScreenIconReact.ReactNodeTo change the icon of the full screen button
goToFirstPageIconReact.ReactNodeTo change the icon of the go to first page button
goToLastPageIconReact.ReactNodeTo change the icon of the go to last page button
rotateClockwiseIconReact.ReactNodeTo change the icon of the rotate clockwise button
rotateCounterClockwiseIconReact.ReactNodeTo change the icon of the rotate counter clockwise button
textSelectionIconReact.ReactNodeTo change the icon of the text selection button
handModeIconReact.ReactNodeTo change the icon of the hand mode button
singlePageIconReact.ReactNodeTo change the icon of the single page button
dualPageIconReact.ReactNodeTo change the icon of the dual page button
pageScrollIconReact.ReactNodeTo change the icon of the page scroll button
verticalScrollIconReact.ReactNodeTo change the icon of the vertical scroll button
horizontalScrollIconReact.ReactNodeTo change the icon of the horizontal scroll button
documentPropertiesIconReact.ReactNodeTo change the icon of the document properties button

Replace the default icons with your own custom icons using the icons prop.

import { RPConfig, RPProvider, RPLayout, RPPages, RPVerticalBar } from '@pdf-viewer/react'
const HeartIcon = (
<svg width="24" height="24" viewBox="0 0 24 24" fill="red" xmlns="http://www.w3.org/2000/svg">
<path d="M12 21s-6-4.35-9-7.69C-1 8.07 3.6 2.6 8.44 6.24L12 9l3.56-2.76C20.4 2.6 25 8.07 21 13.31 18 16.65 12 21 12 21z" />
</svg>
)
const AppPdfViewer = () => {
return (
<RPConfig licenseKey="YOUR_LICENSE_KEY">
<RPProvider src="https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf">
<RPLayout
toolbar={{
topbar: {
component: (
<RPMoreOptions
icons={{
documentPropertiesIcon: HeartIcon
}}
/>
)
}
}}
>
<RPPages />
</RPLayout>
</RPProvider>
</RPConfig>
)
}
export default AppPdfViewer
An image of how React PDF displays with more options dropdown customized icons

Note: Use this same method to change any of the icons listed in RPMoreOptionsIcons.

NameTypeDescription
openFileToolbooleanTo show or hide the open file tool
downloadToolbooleanTo show or hide the download tool
printToolbooleanTo show or hide the print tool
fullscreenToolbooleanTo show or hide the fullscreen tool
jumpNavigationToolbooleanTo show or hide the jump navigation tool
rotateToolbooleanTo show or hide the rotate tool
selectionModeToolbooleanTo show or hide the selection mode tool
viewModeToolbooleanTo show or hide the view mode tool
scrollModeToolbooleanTo show or hide the scroll mode tool
documentPropertiesbooleanTo show or hide the document properties

To hide any tool, set it to false in the slots prop

<RPMoreOptions
slots={{
openFileTool: false,
downloadTool: false,
printTool: false,
fullscreenTool: false,
jumpNavigationTool: false,
rotateTool: false,
selectionModeTool: false,
viewModeTool: false,
scrollModeTool: false
// documentProperties: false (this will show only the documentProperties tool)
}}
/>
An image of how React PDF displays with more options dropdown hidden each tool

Note: If you hide all tools (set slots all to false), the RPMoreOptions toll will automatically hide itself because there are no tools to show.

When the PDF viewer is displayed in mobile view, tools such as openFileTool, downloadTool, printTool, and fullscreenTool are automatically grouped under the RPMoreOptions tool.

An image of how React PDF displays with default mobile view behavior when the PDF viewer is displayed in mobile view

If you want to prevent this behavior, you can set the slots prop to false for these tools.

<RPMoreOptions
slots={{
openFileTool: false,
downloadTool: false,
printTool: false,
fullscreenTool: false
}}
/>
An image of how React PDF displays with prevent mobile view behavior when the PDF viewer is displayed in mobile view

The RPMenuItem is used to create custom menu items in the RPMoreOptions tool. You can add your own icons, labels, tooltips, and click actions.

NameTypeDescription
iconReact.ReactNodeThe icon to display for the menu item
labelstringThe text label displayed for the menu item
tooltipstringThe tooltip text shown when hovering over the menu item
onClick() => void(optional) callback function triggered when the menu item is clicked
menuSeparatorboolean(optional) attribute to add a separator line above or below the menu item
menuSeparatorPosition’top’ | ‘bottom’(optional) position for the separator line when menuSeparator is true

Add a custom menu item to the RPMoreOptions tool using the slotTop or slotBottom prop.

import {
RPConfig,
RPProvider,
RPLayout,
RPPages,
RPMoreOptions,
RPMenuItem
} from '@pdf-viewer/react'
const HeartIcon = (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="red" viewBox="0 0 24 24">
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41 0.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
</svg>
)
const AppPdfViewer = () => {
const handleCustomAction = () => {
console.log('Custom menu item clicked!')
// Add your custom logic here
}
return (
<RPConfig licenseKey="YOUR_LICENSE_KEY">
<RPProvider src="https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf">
<RPLayout
toolbar={{
topbar: {
component: (
<div style={{ marginLeft: 'auto' }}>
<RPMoreOptions
slotTop={
<RPMenuItem
icon={HeartIcon}
label="Custom Action"
tooltip="Perform a custom action"
onClick={handleCustomAction}
/>
}
/>
</div>
)
}
}}
>
<RPPages />
</RPLayout>
</RPProvider>
</RPConfig>
)
}
export default AppPdfViewer
An image of how React PDF displays with more options dropdown with a custom menu item

Use the menuSeparator and menuSeparatorPosition props to add separator lines between menu items in the RPMoreOptions tool.

<RPMoreOptions
slotTop={
<>
<RPMenuItem
icon={HeartIcon}
label="First Item"
tooltip="First menu item"
onClick={() => console.log('First item clicked')}
/>
<RPMenuItem
icon={HeartIcon}
s
label="Second Item"
tooltip="Second menu item with separator"
onClick={() => console.log('Second item clicked')}
menuSeparator={true}
menuSeparatorPosition="bottom"
/>
</>
}
slotBottom={
<>
<RPMenuItem
icon={HeartIcon}
label="Third Item"
tooltip="Third menu item"
onClick={() => console.log('Third item clicked')}
menuSeparator={true}
menuSeparatorPosition="top"
/>
<RPMenuItem
icon={HeartIcon}
label="Fourth Item"
tooltip="Fourth menu item with separator"
onClick={() => console.log('Fourth item clicked')}
menuSeparator={true}
menuSeparatorPosition="top"
/>
</>
}
/>
An image of how React PDF displays with more options dropdown with menu separators

You can use the RPMoreOptions with the RPLayout to create a more options dropdown with a custom toolbar to topbar and leftSidebar. For more information on how to customize your toolbar, check out Customize Toolbar.

<RPLayout
toolbar={{
topbar: {
component: <RPMoreOptions />
},
leftSidebar: {
component: <RPMoreOptions />
}
}}
>
<RPPages />
</RPLayout>
An image of how React PDF displays with more options dropdown with a custom toolbar to topbar and leftSidebar