Barcode

Renders a 1D barcode as inline SVG using JsBarcode. Supports Code128, EAN-13, and UPC-A formats, with configurable dimensions and an optional human-readable value.

Usage

<script>
  import { Barcode } from '@vultra/ui';
</script>

<Barcode value="VULTRA-2024" />

Options

<!-- EAN-13 product barcode, taller bars, no text -->
<Barcode value="4006381333931" format="ean13" height={120} width={3} displayValue={false} />

Props

PropTypeDefaultDescription
valuestringThe value to encode (required)
format'code128' \| 'ean13' \| 'upc''code128'Barcode symbology
heightnumber80Bar height in pixels
widthnumber2Bar width in pixels
displayValuebooleantrueShow the human-readable value under the bars
classstringAdditional classes

The barcode is generated as an inline SVG with a 4px margin. Invalid values are caught and logged instead of breaking the render.

Features

  • Zero-dependency rendering (JsBarcode → inline SVG)
  • Three common symbologies: Code128, EAN-13, UPC
  • Re-renders automatically when value or options change

Install

npx @vultra/cli add barcode