Skip to content

Avaray/svg-barcode-generator

Repository files navigation

SVG Barcode Generator

Simple one-dimensional barcode generator focused on scalability and themability.
Created to be easy to use, lightweight, and compatible with Tailwind CSS.

Supported code formats

Why to use this library

Why you shouldn't use this library

  • It has not been battle-tested yet. Might have bugs.
  • Whether the project will be developed further depends on my willingness to work.

Idea

Among the libraries available on NPM, none met my needs. Some lacked tree shaking, others required complex configurations just to generate decent looking SVG, and some applied colors that couldn’t be easily overridden with Tailwind. So, I decided to create my own library.

Usage

Common

import SvgBarcodeGenerator from "svg-barcode-generator";

const barcode = SvgBarcodeGenerator.generate("7423522549551", "ean_13");

console.log(barcode);

React + TailwindCSS

import SvgBarcodeGenerator from "svg-barcode-generator";

export const YourComponent = () => {
  const barcode = SvgBarcodeGenerator.generate("7423522549551", "ean_13");
  return (
    <div className="p-6 bg-white fill-current text-black">
      <div dangerouslySetInnerHTML={{ __html: barcode }} />
    </div>
  );
};

Materials you can check before use

TODO

  • Check ean_13 (seems to be broken)
  • Add support for upc_e (the last one of planned 1D formats)
  • Add automatic testing

Support the project

If you see potential in this project and want to help - feel free to contribute.

You can contact me on LinkedIn or Discord: avaray_

About

Barcode Generator compatible with Mobile, Browsers and JavaScript Runtimes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published