1.0.1 • Published 2 years ago

@solid-bricks/barcode v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@solid-bricks/barcode

@solid-bricks/barcode · npm

Description

A solidjs <Barcode /> component powered by JsBarcode.

Installation

npm

npm i @solid-bricks/barcode

yarn

yarn add @solid-bricks/barcode

pnpm

pnpm add @solid-bricks/barcode

Examples

Usage

import { render } from 'solid-js/web';
import { Barcode } from '@solid-bricks/barcode';

const root = document.getElementById('app');

if (!root) {
  throw new Error('root node not found');
}

render(() => <Barcode value="ping-pong" />, root);

API Reference

Barcode props

nametyperequireddescription
valuestringyesthe value rendered in the barcode.
onErrorFunctiondefault: console.errorCallback invoked whenever an error occurs while rendering the barcode.
as"svg" \| "img" \| "canvas"default: "svg"The element that displays the barcode.
optionsObjectdefault: {}Additional customization. See JsBarcode wiki for more info.
classstringdefault: undefinedThe element class.
classListRecord<string, boolean>default: undefinedclassList docs
elemPropsJSX.IntrinsicElements['svg'] \| JSX.IntrinsicElements['img'] \| JSX.IntrinsicElements['canvas']default: {}A record of valid element (see as) props.

Barcode options example

{
  width: 2,
  height: 100,
  format: "CODE128",
  displayValue: true,
  fontOptions: "",
  font: "monospace",
  textAlign: "center",
  textPosition: "bottom",
  textMargin: 2,
  fontSize: 20,
  background: "#ffffff",
  lineColor: "#000000",
  margin: 10,
  marginTop: undefined,
  marginBottom: undefined,
  marginLeft: undefined,
  marginRight: undefined
}

More informations are available at https://github.com/lindell/JsBarcode.

Reference

License

MIT