scan-barcode
Overview
scan-barcode launches the barcode scanner which opens a camera view with which app users can scan codes.
Basic Example
<var name="product_barcode" type="text" />
<scan-barcode bind="product_barcode" label="Scan the Product's Barcode" />
Standard Attributes
bind
bindbindlabel
labellabelrequired
requiredrequiredAdvanced Attributes
align-content
align-contentalign-contentalign-label
align-labelalign-labelallow-manual-entry
allow-manual-entryOptional
Type: boolean
Default: true
On unsupported devices, a text input dialog will display for users to manually enter the data. This dialog can be skipped by setting allow-manual-entry to false.
color
colorOptional
Type: string- can be a named color or #HEX value
Default: primary
The main color of the scan-barcode button: Background color of a solid button; border and text color of an outline button.
<scan-barcode label="Scan QR code" color="$:getColor()" />function getColor() {
return "#ffab00";
}disabled
disableddisableddisabled-message
disabled-messageOptional
Type: string (static text, a format string or the return value of a JS/TS function)
Default: unset
When the disabled attribute is set to true the component will display the bound state and direct interactions blocked. The component will appear greyed-out. A message will display indicating the message specified.
extensions
extensionsOptional
Type: EAN_2, EAN_5
Comma-separated list of barcode type extensions.
<var name="product" type="text"/>
<scan-barcode bind="product" extensions="EAN_2,EAN_5" />icon
iconOptional
Type: string
Default: Barcode Scanner Icon
The icon to display on the button, it will be placed on the left of the label by default. The icon can be a Font Awesome icon, an Ionicons icon or an icon or image asset.
icon-color
icon-colorOptional
Type: string
Default: the component's text-color
Specify the color of the button's icon. The icon-color attribute can be a named text-color or #HEX value.
icon-position
icon-positionicon-positionid
ididlabel-case
label-caselabel-caselabel-color
label-colorlabel-coloron-change and on-scan
on-changeon-change and on-scanprompt
promptOptional
Type: string
Default: unset
Prompt text to display on the barcode scanning screen. Message will also display on the manual fallback dialog.
show-if and hide-if
show-ifhide-ifshow-if and hide-ifstyle
styleOptional
Type: solid | outline
Default: solid
The scan-barcode button style conveys importance of a button to the user, and can be set to solid or outline.
<scan-barcode label="Scan the Product's Barcode" style="outline" />
text-color
text-colorOptional
Type: string - can be a named color or #HEX value
Default: If the button's color is a named color, its text color defaults to the _text counterpart of the named color. If the button's color is a #HEX value, its text color defaults to a high contrasting color.
Specify the color of the scan-barcode button's label.
<scan-barcode label="Scan the Product's Barcode" text-color="#ffff00" />
types
typesOptional
Comma-separated list of barcode types to attempt to scan.
<var name="product_code" type="text"/>
<scan-barcode bind="product_code" types="QR_CODE,UPC_A,UPC_E" />Supported Barcode Formats
Product barcodes:
UPC_A, UPC_E, EAN_8, EAN_13, RSS_14 (all variants), RSS_EXPANDED (most variants).
UPC_A, UPC_E, EAN_8, EAN_13
Other 1D barcodes:
CODE_39, CODE_93, CODE_128, ITF, CODABAR
CODE_39, CODE_128
2D barcodes:
QR_CODE, DATA_MATRIX, AZTEC (beta quality), PDF_417
QR_CODE, DATA_MATRIX
Component Methods
The following component methods are available when an id is assigned to the component and component.scanBarcode({id:'my-id'}) is called from JS/TS:
scanBarcode
scanBarcodeProgrammatically opens the barcode scanner to allow the user to capture a barcode bound to the scan-barcode component.
scrollIntoView
scrollIntoViewProgrammatically scroll until the scan-barcode component is visible in the view.
Last updated
