@adrianso/react-native-barcode-builder
React Native component to generate barcodes.
Uses JsBarcode for encoding of data.
Uses @react-native-community/react-native-svg instead of @react-native-community/art.
Getting started
Step 1
Install @adrianso/react-native-barcode-builder
and dependencies:
npm install @adrianso/react-native-barcode-builder react-native-svg
or
yarn add @adrianso/react-native-barcode-builder react-native-svg
Step 2
Start using the component
import Barcode from '@adrianso/react-native-barcode-builder';
<Barcode value="Hello World" format="CODE128" />;
or you can invoke the barcodeToSvg function to convert any barcode to and SVG string
import { barcodeToSvg } from '@adrianso/react-native-barcode-builder';
const svg = barcodeToSvg({
value: 'Hello world!',
});
You can find more info about the supported barcodes in the JsBarcode README.
Properties
Property | Description |
---|
value | What the barcode stands for (required). |
format | Which barcode type to use (default: CODE128). |
width | Width of a single bar (default: 2) |
height | Height of the barcode (default: 100) |
text | Override text that is displayed. |
lineColor | Color of the bars and text (default: #000000) |
background | Background color of the barcode (default: #ffffff) |
onError | Handler for invalid barcode of selected format |