react-jsbarcode
Version:
JSBarcode component for React
69 lines (45 loc) • 2.61 kB
Markdown
# react-jsbarcode
[](https://www.npmjs.com/package/react-jsbarcode)
[](https://snyk.io/test/github/iamchathu/react-jsbarcode)
[](https://codeclimate.com/github/iamchathu/react-jsbarcode)
[](https://www.codacy.com/gh/iamchathu/react-jsbarcode/dashboard?utm_source=github.com&utm_medium=referral&utm_content=iamchathu/react-jsbarcode&utm_campaign=Badge_Grade)
[](https://raw.githubusercontent.com/iamchathu/react-jsbarcode/master/LICENSE)
[](https://twitter.com/intent/tweet?text=Barcode+for+react&url=https%3A%2F%2Fgithub.com%2Fiamchathu%2Freact-jsbarcode)
## About
This is a [React](https://reactjs.org) component wrapping up [jsbarcode](<[https://](https://github.com/lindell/JsBarcode)>). Written as a React functional component using React hooks. <ReactBarcode />
## Demo
[](https://codesandbox.io/s/react-jsbarcode-2659g?fontsize=14&hidenavigation=1&theme=dark)
[](https://stackblitz.com/edit/react-jsbarcode?file=src%2FApp.tsx)
## Installation
using NPM
```bash
npm i react-jsbarcode
```
using yarn
```bash
yarn add react-jsbarcode
```
using PNPM
```bash
pnpm add react-jsbarcode
```
## Usage
- Basic usage
```tsx
import { ReactBarcode } from 'react-jsbarcode';
const App = () => {
return <ReactBarcode value="ABC123" />;
};
```
- Advanced usage
```tsx
import { ReactBarcode } from 'react-jsbarcode';
const App = () => {
return <ReactBarcode value="ABC123" options={{ format: 'code128' }} renderer="svg" />;
};
```
For all options refer jsbarcode [wiki](https://github.com/lindell/JsBarcode/wiki/Options).
### Renderers
JSBarcode supports rendering to SVG, image and canvas. Default renderer is 'svg'.
[](https://codesandbox.io/s/react-jsbarcode-2659g?fontsize=14&hidenavigation=1&theme=dark)
[](https://stackblitz.com/edit/react-jsbarcode?file=src%2FApp.tsx)