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
v-modelis the code. Enter, or a scanner, emitsscanwith 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. clearOnScanempties the field after each scan, for a run of scans.- A hidden status line says each scanned code.
labelsets the name of the field (default "Barcode" or "SKU"). Change the other words withlabelsor a label pack:hint,valid,invalid, andscanned(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
| Name | Type | Default | Description |
|---|---|---|---|
kind | "barcode" | "sku" | "barcode" | `barcode` takes GS1 numbers and checks them; `sku` takes your own codes |
label | string | — | |
clearOnScan | boolean | false | clear the field after each scan, for a run of scans |
labels | Partial<{ hint: string; valid: string; invalid: string; scanned: (code: string) => string; }> | — | |
modelValue | string | "" |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string] | |
scan | [code: string] |