Example: Customize the rotate buttons

The Rotate component provided by the Rotate plugin is used to create a custom rotate button. It has two properties:

*: Required parameter

direction*RotateDirectionThe rotate direction2.0.0
childrenRenderRotateProps => ReactElementThe render prop2.0.0

RotateDirection is an enum with two possible values:

  • Backward if you want to rotate counterclockwise
  • Forward if you want to rotate clockwise

The sample code below creates a button that clicking it will rotate the document counterclockwise:

import { RenderRotateProps, RotateDirection, rotatePlugin } from '@react-pdf-viewer/rotate';

// Your render function
const rotatePluginInstance = rotatePlugin();
const { Rotate } = rotatePluginInstance;

<Rotate direction={RotateDirection.Backward}>
    (props: RenderRotateProps) => (
                backgroundColor: '#357edd',
                border: 'none',
                borderRadius: '4px',
                color: '#ffffff',
                cursor: 'pointer',
                padding: '8px',
            Rotate backward

(The sample code)

Related example