Skip to content
Calm motion: animations on this site only fade, with no movement

SKU field ​

A field for a barcode or a SKU that takes a scanner and checks the code

Takes product codes in a warehouse, a shop, or an ERP. A SKU (stock keeping unit) is your own code for a product. Most barcode scanners act as a keyboard: they type the code fast and press Enter.

Basic

Scan or type the code, then press Enter.

Scan or type the code, then press Enter.

  • v-model is the code. Enter, or a scanner, emits scan with it.
  • With kind="barcode" (default), the field keeps only digits. It checks GS1 numbers (EAN-8, UPC-A, EAN-13, and GTIN-14) with their check digit. A wrong number is marked as not valid, says so, and does not scan.
  • With kind="sku", the field makes the code upper case and keeps letters, digits, dots, dashes, and the "_" sign. It does not check the code.
  • clearOnScan empties the field after each scan, for a run of scans.
  • A hidden status line says each scanned code.
  • label sets the name of the field (default "Barcode" or "SKU"). Change the other words with labels or a label pack: hint, valid, invalid, and scanned (a function).

The gs1Valid function checks a GS1 number. It is exported for your own views.

Usage ​

ts
import { BlessSkuField } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
kind"barcode" | "sku""barcode"`barcode` takes GS1 numbers and checks them; `sku` takes your own codes
labelstring—
clearOnScanbooleanfalseclear the field after each scan, for a run of scans
labelsPartial<{ hint: string; valid: string; invalid: string; scanned: (code: string) => string; }>—
modelValuestring""

Events

NamePayloadDescription
update:modelValue[value: string]
scan[code: string]

Released under the MIT License. Character names and artwork belong to their owners.