Class TwBarcode
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Shows a value, such as a product number or tracking reference, as a scannable one-dimensional barcode.
public class TwBarcode : TwEncodedSymbolBase<Barcode>, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
- Inheritance
-
TwBarcode
- Implements
- Inherited Members
Remarks
The bars are drawn as a single SVG path, so they stay sharp at any size. The barcode is only re-encoded when
Value, Format or QuietZone change. Nothing is rendered when Value is empty or
cannot be encoded in the chosen Format; use TryEncode(string?, BarcodeFormat, out Barcode?) to check a
value beforehand.
Accessibility: the barcode is exposed as an image named "Barcode: " followed by its text, so people who cannot
scan it still learn what it holds. Set AriaLabel to describe it instead.
Constructors
TwBarcode()
public TwBarcode()
Properties
Format
Gets or sets the barcode format.
[Parameter]
public BarcodeFormat Format { get; set; }
Property Value
Remarks
Defaults to Code128, which holds any ASCII text.
ShowText
Gets or sets whether to print the human readable text under the bars.
[Parameter]
public bool ShowText { get; set; }
Property Value
Remarks
Defaults to true, so the value can still be typed in when a scan fails.
Size
Gets or sets the height of the bars. The width follows from it and the length of the value.
[Parameter]
public BarcodeSize Size { get; set; }
Property Value
encodingSettings
Gets the component's other settings that change the encoding, so a change to any of them re-encodes.
protected override object? encodingSettings { get; }
Property Value
labelKey
Gets the resource key of the default accessible name, a format string taking labelText.
protected override string labelKey { get; }
Property Value
labelText
Gets the text the default accessible name describes. Defaults to Value.
protected override string labelText { get; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
TryEncode(string, out Barcode?)
Encodes a value.
protected override bool TryEncode(string value, out Barcode? encoded)
Parameters
valuestringThe non-empty value to encode.
encodedBarcodeThe encoded symbol, or null when the value cannot be encoded.