Blazorise QR Code component

A component used to generate QR codes.

QR codes are great for presenting short amounts of information to people who can scan them rapidly with their smartphones. Because most smartphones come with built-in QR code scanners, simply pointing the camera at a QR code will decode it, allowing the user to browse a website, dial a phone number, read a message, and so on.

Installation

NuGet

Install extension from NuGet.
Install-Package Blazorise.QRCode

Imports

In your main _Imports.razor add:
@using Blazorise.QRCode

Examples

Basic

To generate a QR code you only need to define a Value parameter.
<QRCode Value="https://blazorise.com" Alt="QRCode image" />

Color

Use the DarkColor and LightColor attributes to modify the QR code's colors. You should always ensure good contrast for optimal compatibility with QR code scanners.
<QRCode Value="https://blazorise.com" Alt="QRCode image" DarkColor="#7474ed" />

Error Correction

QR codes can be rendered with various levels of error correction that can be set using the EccLevel attribute. This example generates four codes with the same value using different error correction levels.
<QRCode Value="https://blazorise.com" Alt="QRCode image" EccLevel="EccLevel.L" PixelsPerModule="4" />
<QRCode Value="https://blazorise.com" Alt="QRCode image" EccLevel="EccLevel.M" PixelsPerModule="4" />
<QRCode Value="https://blazorise.com" Alt="QRCode image" EccLevel="EccLevel.Q" PixelsPerModule="4" />
<QRCode Value="https://blazorise.com" Alt="QRCode image" EccLevel="EccLevel.H" PixelsPerModule="4" />

Custom Icon

Placing an icon in the middle of <QRCode> is very simple. You just need to set the Icon parameter. It can be in base64 format, or an absolute URL.

Please be aware that placing an icon in the middle will also cover part of the QR code and make it unreadable. So it would be best to increase the error level by setting the EccLevel parameter.

<QRCode Value="https://blazorise.com" Alt="QRCode image" EccLevel="EccLevel.H" Icon="@base64PngIcon" />
@code {
    string base64PngIcon = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABmJLR0QA/wD/AP+gvaeTAAANsElEQVR42u2deXCU5RnA431XkZBdwiEelXoWsdpWW9QahewmsbSltVYhoa1tp+3YTtuhnbbTtNNDe4g5AGO1dtAZ2zgcSw40SUvAaDV44AmKkny7JIQgyR7fbpBAts8LmxBCEnLs8R2/38wzzPDnt88v7/u8z3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/yzN8V/O1wbSUTtk5MXbBQ3ccxdhOnQGWoiSz6RNxOGsSUqtm1Blg3RHl0GlF75ax1BkPZexw8AXB+vVJ3/VB2q4RPEf2X3VBHV8NbMdfHG1nqaXZQ1OnY+TwakoivhLYnhUTfVNiO4YPSuiqznh8RtPpfBmA/vVJZvNs6gwAAAAAAAAAAAAAAAAAgBTzf9R8pQcJ2ipLAAAAAElFTkSuQmCC";
}

Best Practices

Set the Alt property

To optimize your web for SEO, define the Alt parameter to describe the QR image content, eg. Alt="QRCode image".

Increase Error Correction Level for Images

Placing an image within the QRCode can make it unreadable, so it is best to increase the error level(EccLevel) of the code so that the QR scanners can easily read it.

API

Attributes

Name Description Type Default
Value Value used for QR code generation. string
Payload Custom payload used for QR code generation. PayloadGenerator.Payload null
Alt Image alt text. string null
EccLevel The level of error correction to use. EccLevel L
DarkColor Color used as dark color. #000000
LightColor Color used as light color. #ffffff
PixelsPerModule Pixels per module. int 10
DrawQuietZones Draw quiet zones (blank margins around QR Code image). bool true
Icon The icon that is places in the middle of the QRCode, can be in base64 format or an absolute url. string null
IconSizePercentage Defines how much space the icon will occupy within the QRCode. int 40
IconBorderWidth Defines how large the borders will be for the icon that is placed within the QRCode. int 0
On this page