ReactToPrint - Print React components in the browser
Print React components in the browser. Supports Chrome, Safari, Firefox and EDGE
So you've created a React component but would love to give end users the ability to print out the contents of that component. This package aims to solve that by popping up a new print window with CSS styles copied over as well.
Install
npm install react-to-print --save-dev
Usage
API
<ReactToPrint />
The component accepts the following props:
Name | Type | Description |
---|---|---|
trigger |
function | A function that returns a React Component or HTML element |
content |
function | A function that returns a component reference value. The content of this reference value is then used for print |
copyStyles |
boolean | Copies all <style> and <link type="stylesheet" /> from inside the parent window into the print window. (default: true) |
onBeforePrint |
function | A callback function that triggers before print |
onAfterPrint |
function | A callback function that triggers after print |