react-native-barcoder
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

React Native Barcoder

alt text

npm install react-native-barcoder

A minimal package for displaying a barcode on react-native.

import Barcode from 'react-native-barcoder';

const options = { /* add your options here*/ }

<Barcode value="barcoder" options={options}/>

features

  • Support for all types of barcodes including EAN/UPC
  • No external dependencies required for running the code
  • Easy customization taking jsbarcode as an example

options

set up the options parameter

interface Options = {
  format: Format;
  width: number;
  height: number;
  background: string;
  color: string;
  displayValue: boolean;
  flat: boolean;
  lastChar: boolean;
};

regarding each value inside options:

Value Type Default Comment
format Format 'CODE128' the format you want to use to display the barcode
width int 2 the width of the barcode
height int 100 the height of the barcode
background string white the background color of the object
color string black the color of the bars of the barcode
displayValue boolean true display/hide the string value of the barcode
flat boolean false for EAN/UPC only, show/hide barcode guards
lastChar char null display a last character for EAN13 barcodes

formats

Here is a list of supported formats

CODE39 | CODE128 | CODE128A | CODE128B | CODE128C
EAN13 | EAN8 | EAN5 | EAN2
UPC | UPCE
ITF14 | ITF
MSI | MSI10 | MSI11 | MSI1010 | MSI1110
pharmacode | codabar | GenericBarcode

margins

you can set the margins directly on the element:

<Barcode value="barcoder" options={options} marginLeft={40}/>

development

You can try out the code locally using expo after cloning! Change the main directory in the package.json to 'index.js'

{
    "name": "react-native-barcoder",
    "main": "dist/index.js", // <-- change this to "index.js"
    /* ... */
}

Then customize the App.tsx file as you like and run

npm run dev

aknowledgements

This code relies on jsbarcode's math files to transform the value into a binary.

contributions

Any contributions are welcome!

Package Sidebar

Install

npm i react-native-barcoder

Weekly Downloads

298

Version

0.2.0

License

MIT

Unpacked Size

71.6 kB

Total Files

117

Last publish

Collaborators

  • theblindhawk