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
- Host: GitHub
- URL: https://github.com/eyelly-wu/react-printer
- Owner: eyelly-wu
- License: mit
- Created: 2019-08-03T09:00:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-25T03:36:12.000Z (over 3 years ago)
- Last Synced: 2025-02-27T07:34:39.632Z (over 1 year ago)
- Topics: print, printer, react, react-print, react-printer
- Language: JavaScript
- Homepage:
- Size: 136 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)