Barcodes & QR

BarcodeControl · QrCodeControl

Nine linear symbologies and QR codes, encoded on the server and drawn as inline SVG.

Overview

Both controls hand Value to ZXing.Net and render the result as an <svg role="img">, so there is no image request and the code scales with its box. A value the symbology cannot encode shows the encoder's message in place of the code instead of throwing. BarcodeControl picks the symbology with Type; QrCodeControl takes a Size and an ErrorCorrection level.

Examples

#Barcode

Pick a symbology and edit the value. Each one has its own rules: EAN-13 wants 12 or 13 digits, UPC-A 11 or 12, ITF an even count, Code 39 upper-case letters and digits. Break a rule and the control's own error replaces the bars.

Example
Razor
C#
FLEX-9988

#QR code

Higher error correction survives more damage to the printed code but needs more modules for the same text. Size is the rendered width and height in pixels; the module grid stays sharp because the SVG uses shape-rendering="crispEdges".

Example
Razor
C#
Size 140 px

Documentation

BarcodeControl parameters

ParameterTypeDefaultDescription
Valuestring"FLEX-12345"Text to encode. Empty renders nothing.
TypeBarcodeTypeCode128Symbology; see the table below.
ShowTextbooltrueDraws the value under the bars.
ForegroundColor / BackgroundColorstring#000000 / #ffffffBar and text colour; background rectangle. Any CSS colour.
BarHeightint50Bar height in SVG units (pixels at default size); at least 1.
Width / Heightstring?nullCSS size of the SVG. Unset means the natural size: one unit per module plus 20 units of quiet zone in total, and the bar height plus 27 (text) or 10.
AriaLabelstring?nullOverrides the default "Type barcode: value".
CssClass / Style (base)string?nullOn the fx-barcode frame. Visible from the base is not applied.
(unmatched attributes)Dictionary<string,object>—Forwarded to the frame <div>.

BarcodeType

PropertyTypeDefaultDescription
Code128—Any ASCII text; the densest general-purpose choice.
Code39—Upper-case letters, digits and - . $ / + % and space.
Code93—Same character set as Code 39, more compact.
Ean8 / Ean13—7 or 8 digits; 12 or 13 digits. The check digit is computed when omitted and verified when given.
UpcA / UpcE—11 or 12 digits; 7 or 8 digits.
Itf—Digits, even count (Interleaved 2 of 5).
Codabar—Digits and - $ : / . +; A–D start and stop characters are optional and added when missing.

QrCodeControl parameters

ParameterTypeDefaultDescription
Valuestring"FlexCore"Text to encode, UTF-8. Empty renders nothing.
Sizeint150Rendered width and height in pixels; the module count comes from the text length and level.
ForegroundColor / BackgroundColorstring#000000 / #ffffffModule and background colour.
ErrorCorrectionQrErrorCorrectionLevelMediumRedundancy level; see below.
AriaLabelstring?nullOverrides the default "QR code: value".
CssClass / Style (base)string?nullOn the fx-qrcode frame.

QrErrorCorrectionLevel

PropertyTypeDefaultDescription
Low—About 7% of the symbol can be unreadable.
Medium—About 15%.
Quartile—About 25%.
High—About 30%; the largest symbol for a given text.

Read-only properties

MethodInputsReturnsDescription
BarcodeControl.ErrorMessage—string?"Cannot encode Type barcode: …" from the encoder, or null.
QrCodeControl.ErrorMessage—string?"Cannot encode QR code: …", or null.

CSS classes

ClassEffect
fx-barcode · fx-barcode-errorWhite rounded frame with a hairline border and light shadow; the error text inside it.
fx-qrcode · fx-qrcode-errorSame frame with an 8px radius; the error text inside it.

Neither stylesheet reads a --fx-* variable. Colours of the code itself come from ForegroundColor and BackgroundColor; the frame is fixed in CSS.

Keyboard and accessibility

  • The SVG is role="img" with an aria-label that defaults to "Type barcode: value" or "QR code: value". Set AriaLabel when the value is not meaningful to read out.
  • An encoding error renders as role="alert" text inside the frame.
  • Nothing here is focusable or interactive; the controls above the codes are ordinary FlexCore inputs.
  • The barcode's human-readable text is drawn inside the SVG at 11px monospace; it is not selectable. Print the value next to the code if users must copy it.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.