svelte-barcode-scanner
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

Svelte Barcode Scanner

A Svelte component for detecting QR-codes, EAN-barcodes and other barcode formats.

NPM Type Definitions NPM Version GitHub Actions Workflow Status GitHub License

Installation

npm install svelte-barcode-scanner

or

pnpm add svelte-barcode-scanner

Usage

<script lang="ts">
	import { BarcodeScanner } from 'svelte-barcode-scanner';
</script>

<BarcodeScanner />

The <BarcodeScanner /> component is responsive and fills the available space with object-fit: cover.

This enables you to embed the component inside a div with a fixed aspect ratio to get a predictable size regardless of the aspect ratio of the camera feed:

<script lang="ts">
	import { BarcodeScanner } from 'svelte-barcode-scanner';
</script>

<div class="barcode-scanner">
	<BarcodeScanner />
</div>

<style>
	.barcode-scanner {
		width: 100%;
		max-width: 384px;
		aspect-ratio: 1;
	}
</style>

A live demo and an API reference is being worked on.

License

MIT

Package Sidebar

Install

npm i svelte-barcode-scanner

Weekly Downloads

7

Version

0.1.6

License

MIT

Unpacked Size

19.8 kB

Total Files

11

Last publish

Collaborators

  • ollemansson