Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-barcode

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-barcode

A light-weight and high-performance component to generate barcode for Svelte.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
205
increased by22.75%
Maintainers
2
Weekly downloads
 
Created
Source

svelte-barcode

A light-weight and high-performance component to generate barcode for Svelte.

NPM JavaScript Style Guide

🔧 Install

svelte-barcode is available on npm. It can be installed with the following command:

npm install svelte-barcode --save

svelte-barcode is available on yarn as well. It can be installed with the following command:

yarn add svelte-barcode --save

Note: Install as a dev dependency ( npm install svelte-barcode -D ) ( yarn add svelte-barcode --dev ) if using Sapper to avoid a SSR error.

💡 Usage

<script>
  import Barcode from 'svelte-barcode';
</script>

<Barcode
  value={'svelte-barcode'}
  elementTag={'canvas'}
  options={{
    format: 'CODE128',
    width: 2,
    height: 100,
    text: '',
    textAlign: 'center',
    textPosition: 'bottom',
    textMargin: 2,
    fontSize: 20,
    background: '#ffffff',
    lineColor: '#000000',
  }}
/>

props

PropsTypeDefaultRequireDescription
valuestring✔️Text to generate.
elementTag'img' | 'canvas' | 'svg''img'
optionsanyOptions to generate.

options

OptionsTypeDefaultRequireDescription
formatstring?autoSelect which barcode type to use. Please check the wikipage of the different barcode types for more information.
widthnumber?2The width option is the width of a single bar.
heightnumber?100The height of the barcode.
displayValueboolean?true
textstring?undefinedOveride the text that is diplayed
fontOptionsstring?''With fontOptions you can add bold or italic text to the barcode.
fontstring?'monospace'Define the font used for the text in the generated barcode. This can be any default font or a font defined by a @font-face rule.
textAlignstring?'center'Set the horizontal alignment of the text. Can be left / center / right.
textPositionstring?'bottom'Set the vertical position of the text. Can be bottom / top.
textMarginnumber?2Set the vertical position of the text. Can be bottom / top.
fontSizenumber?20Set the size of the text.
backgroundstring?'#ffffff'Set the background of the barcode.
lineColorstring?'#000000'Set the color of the bars and the text.
marginnumber?10Set the space margin around the barcode. If nothing else is set, all side will inherit the margins property but can be replaced if you want to set them separably.
marginTopnumber?undefined
marginBottomnumber?undefined
marginLeftnumber?undefined
marginRightnumber?undefined
flatboolean?falseOnly for EAN8 / EAN13

❗ Issues

If you think any of the svelte-barcode can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.

🌟 Contribution

We'd love to have your helping hand on contributions to svelte-barcode by forking and sending a pull request!

Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)

How to contribute:

  • Open pull request with improvements
  • Discuss ideas in issues
  • Spread the word
  • Reach out with any feedback

⚖️ License

The MIT License License: MIT

Keywords

FAQs

Package last updated on 07 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc