QR Code

<wa-qr-code> Stable Since 2.0

QR codes encode a URL or other short text into a scannable image, rendered client-side using the Canvas API. Use them to share links, contact info, or Wi-Fi credentials that visitors can scan with a phone.

QR codes are useful for providing small pieces of information to users who can quickly scan them with a smartphone. Most smartphones have built-in QR code scanners, so simply pointing the camera at a QR code will decode it and allow the user to visit a website, dial a phone number, read a message, etc.


Examples

Link to This Section

Size

Link to This Section

Use the size attribute to change the size of the QR code.

Colors

Link to This Section

The QR code's fill color is determined by the current text color. To change it, set the CSS color property on the host element or an ancestor element.

The canvas is always transparent, so use the background or background-color CSS property on the host element to set a background color.

A quiet zone is the blank space around a QR code that helps scanners detect it more reliably. Use the padding CSS property on the host element to add one.

Radius

Link to This Section

Create a rounded effect with the radius attribute.

Error Correction

Link to This Section

QR codes can be rendered with various levels of error correction that can be set using the error-correction attribute. This example generates four codes with the same value using different error correction levels.

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/qr-code/qr-code.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/qr-code/qr-code.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/qr-code/qr-code.js';

To import this component for React 18 or below, use the following code:

import WaQrCode from '@awesome.me/webawesome/dist/react/qr-code/index.js';

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

CSS parts

Link to This Section

Learn more about CSS parts.

Need a hand? Report a bug Ask for help
    No results