An open API service indexing awesome lists of open source software.

https://github.com/eyelly-wu/react-printer

A simple react component for partial printing on the browser
https://github.com/eyelly-wu/react-printer

print printer react react-print react-printer

Last synced: 23 days ago
JSON representation

A simple react component for partial printing on the browser

Awesome Lists containing this project

README

          

# React-Printer

React-Printer is a simple react component for partial printing on the browser

## Installation

**NPM**
```
npm i -S @eyelly/react-printer
```
**CDN**
```HTML

```
## Usage & Example

**In Module**
```javascript
import React, { useRef } from 'react'
import Printer from '@eyelly/react-printer'

function App() {
const printContent = useRef(null)

return (
<>

this is content to print

this is normal content


Printer

>
)
}
```
**In HTML**
```








function App(){
const printContent = React.useRef(null)
return (
<React.Fragment>
<div ref={printContent}> this is content to print </div>
<div> this is normal content </div>
<Printer content={printContent}>
<button>printer</button>
</Printer>
</React.Fragment>
)
}

ReactDOM.render( <App/> , document.getElementById('app') )

```
## API

| Property | Description | Type | Default |
| :-------- | :----------------------------------- | :-------------------- | :------ |
| content | content to be printed | {current:HTMLElement} | - |
| shotcut | enable browser printing shortcut | boolean | true |
| newWindow | open a new window to print | boolean | false |
| title | the title of the newly opened window | boolean | - |

## License

[MIT](https://github.com/eyelly-wu/react-printer/blob/master/LICENSE)