Class TwQrCode
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Shows text, such as a URL, as a scannable QR code.
public class TwQrCode : TwEncodedSymbolBase<QrMatrix>, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
- Inheritance
-
TwQrCode
- Implements
- Inherited Members
Remarks
The code is drawn as a single SVG path, so it stays sharp at any size and adds only two elements to the page.
It is only re-encoded when Value, ErrorCorrection, BoostErrorCorrection
or QuietZone change. Nothing is rendered when Value is empty or too long to fit; use
TryEncode(string?, QrEncodeOptions?, out QrMatrix?) to check a value beforehand.
Accessibility: the code is exposed as an image named "QR code: " followed by its Value, so people
who cannot scan it still learn what it holds. Set AriaLabel to describe it instead (for example
"Scan to open the menu"), and show the link as text nearby so everyone can use it without a camera.
Constructors
TwQrCode()
public TwQrCode()
Properties
BoostErrorCorrection
Gets or sets whether to raise ErrorCorrection when that does not make the code any denser.
[Parameter]
public bool BoostErrorCorrection { get; set; }
Property Value
Remarks
Defaults to true.
ErrorCorrection
Gets or sets the minimum share of the code that can be damaged or covered and still scan.
[Parameter]
public QrErrorCorrection ErrorCorrection { get; set; }
Property Value
Remarks
Defaults to Medium. Higher levels make a denser code for the same text.
Size
Gets or sets the size of the QR code.
[Parameter]
public QrCodeSize 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
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
TryEncode(string, out QrMatrix?)
Encodes a value.
protected override bool TryEncode(string value, out QrMatrix? encoded)
Parameters
valuestringThe non-empty value to encode.
encodedQrMatrixThe encoded symbol, or null when the value cannot be encoded.