Example: Customize the buttons to switch the selection mode

The SwitchSelectionMode component provided by the Selection Mode plugin is used to create a custom switching button. It has two properties:

*: Required parameter

childrenRenderSwitchSelectionModeProps => ReactElementThe render prop2.0.0
mode*SelectionModeThe selection mode2.0.0

The sample code below creates a button that clicking it will switch to the hand selection mode:

import { RenderSwitchSelectionModeProps, SelectionMode } from '@react-pdf-viewer/selection-mode';

// Your render function
const selectionModePluginInstance = selectionModePlugin();
const { SwitchSelectionMode } = selectionModePluginInstance;

<SwitchSelectionMode mode={SelectionMode.Hand}>
    (props: RenderSwitchSelectionModeProps) => (
                backgroundColor: '#357edd',
                border: 'none',
                borderRadius: '4px',
                color: '#ffffff',
                cursor: 'pointer',
                padding: '8px',
            Hand tool

(The sample code)

Related example