Use the default buttons to switch the selection mode

The `SwitchSelectionModeButton` component provided by the Selection Mode plugin accepts one prop named `mode` that represents the selection mode.
// Switch to the hand selection mode
<SwitchSelectionModeButton mode={SelectionMode.Hand} />
// Switch to the text selection mode
<SwitchSelectionModeButton mode={SelectionMode.Text} />
The following example uses the default button to switch the selection mode.
import { SelectionMode } from '@react-pdf-viewer/selection-mode';
// Your render function
const selectionModePluginInstance = selectionModePlugin();
const { SwitchSelectionModeButton } = selectionModePluginInstance;
return (
<div
className="rpv-core__viewer"
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
display: 'flex',
flexDirection: 'column',
height: '100%',
}}
>
<div
style={{
alignItems: 'center',
backgroundColor: '#eeeeee',
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
display: 'flex',
justifyContent: 'center',
padding: '4px',
}}
>
<div style={{ padding: '0px 2px' }}>
<SwitchSelectionModeButton mode={SelectionMode.Hand} />
</div>
<div style={{ padding: '0px 2px' }}>
<SwitchSelectionModeButton mode={SelectionMode.Text} />
</div>
</div>
<div
style={{
flex: 1,
overflow: 'hidden',
}}
>
<Viewer fileUrl="/assets/pdf-open-parameters.pdf" plugins={[selectionModePluginInstance]} />
</div>
</div>
);

See also