Web Awesome (ViUR)

Font Awesome
Try SSR Server-side rendering (SSR) generates component HTML on the server before the page loads, improving SEO and initial load time. Use the switch to see Web Awesome components render with and without SSR.
Search this website ⌘KCtrl+K Light Dark System Docs Select Color Scheme Default Awesome Shoelace Active Brutalist Glossy Matter Mellow Playful Premium Tailspin Docs Select Theme View Project on GitHub Star Project on GitHub
Start Components Docs Help
Web Awesome Font Awesome Build Awesome
Search this site… /
Try SSR Server-side rendering (SSR) generates component HTML on the server before the page loads, improving SEO and initial load time. Use the switch to see Web Awesome components render with and without SSR.
Light Dark System Docs Select Color Scheme Default Awesome Shoelace Active Brutalist Glossy Matter Mellow Playful Premium Tailspin Docs Select Theme

Getting Started

  • Installation
  • Usage
  • Forms
  • Localization
  • Frameworks
  • Using with AI
  • Figma Design Kit ProThis requires access to Web Awesome Pro
  • Server Rendering

Resources

  • Accessibility
  • Browser Support
  • Contributing
  • Patterns ProPatterns require access to Web Awesome Pro
  • Migrating from Shoelace
  • Visual Tests
  • Changelog
  • Help & Support

Theming & Utilities

  • Overview
  • Built-in Themes
  • Color Palettes
  • Design Tokens
  • Customizing & Theming
  • CSS Utilities

ViUR Components

  • Alert
  • Combobox
  • Pagination
  • Table Wrapper

Actions

  • Button
  • Button Group
  • Copy Button
  • Dropdown
    • Dropdown Item

Forms

  • Checkbox
  • Checkbox Group
  • Color Picker
  • Input
  • Known Date
  • Number Input
  • Radio Group
    • Radio
  • Rating
  • Select
    • Option
  • Slider
  • Switch
  • Textarea
  • Time Input
  • Data Grid Planned A Web Awesome Kickstarter stretch goal!

Layout

  • Accordion
    • Accordion Item
  • Card
  • Details
  • Dialog
  • Divider
  • Drawer
  • Page
  • Scroller
  • Split Panel

Navigation

  • Breadcrumb
    • Breadcrumb Item
  • Tab Group
    • Tab
    • Tab Panel
  • Tree
    • Tree Item

Feedback

  • Badge
  • Callout
  • Progress Bar
  • Progress Ring
  • Skeleton
  • Spinner
  • Tag
  • Tooltip

Media

  • Animated Image
  • Avatar
  • Carousel
    • Carousel Item
  • Comparison
  • Icon
  • Markdown
  • QR Code
  • Zoomable Frame

Data Viz

  • Advanced Usage

Helpers

  • Animation
  • Format Bytes
  • Format Date
  • Format Number
  • Include
  • Intersection Observer
  • Mutation Observer
  • Popover
  • Popup
  • Random Content
  • Relative Time
  • Resize Observer

QR Code

  • Examples
  • Size
  • Colors
  • Radius
  • Error Correction
  • Images
  • Image Coverage
  • Importing
  • Attributes & Properties
  • CSS Parts
On This Page...
  • Examples
  • Size
  • Colors
  • Radius
  • Error Correction
  • Images
  • Image Coverage
  • Importing
  • Attributes & Properties
  • CSS Parts

QR Code

<wa-qr-code>
Stable Media 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.

<div class="qr-overview">
  <wa-qr-code value="https://webawesome.com/" label="Scan this code to visit Web Awesome on the web!"></wa-qr-code>

  <wa-divider></wa-divider>

  <wa-input maxlength="255" with-clear label="Value">
    <wa-icon slot="start" name="link"></wa-icon>
  </wa-input>
</div>

<script>
  const container = document.querySelector('.qr-overview');
  const qrCode = container.querySelector('wa-qr-code');
  const input = container.querySelector('wa-input');

  customElements.whenDefined('wa-qr-code').then(() => {
    qrCode.updateComplete.then(() => {
      input.value = qrCode.value;
      input.addEventListener('input', () => (qrCode.value = input.value));
    });
  });
</script>

<style>
  .qr-overview {
    max-width: 256px;
  }

  .qr-overview wa-input {
    margin-top: 1rem;
  }
</style>

Examples

Link to This Section

Size

Link to This Section

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

<wa-qr-code value="https://webawesome.com/" size="64"></wa-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.

<wa-qr-code
  value="https://webawesome.com/"
  style="
    color: var(--wa-color-indigo-20);
    background-color: var(--wa-color-indigo-90);
    border-radius: var(--wa-border-radius-m);
    padding: 1rem;
  "
></wa-qr-code>

Corner Color

Link to This Section

You can change the color of the corners to be different from the main element with the --corner-color custom property.

<wa-qr-code value="https://webawesome.com/" style="--corner-color: var(--wa-color-brand)"></wa-qr-code>

Radius

Link to This Section

Create a rounded effect with the radius attribute.

<wa-qr-code value="https://webawesome.com/" radius="0.5"></wa-qr-code>

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.

<div class="qr-error-correction">
  <wa-qr-code value="https://webawesome.com/" error-correction="L"></wa-qr-code>
  <wa-qr-code value="https://webawesome.com/" error-correction="M"></wa-qr-code>
  <wa-qr-code value="https://webawesome.com/" error-correction="Q"></wa-qr-code>
  <wa-qr-code value="https://webawesome.com/" error-correction="H"></wa-qr-code>
</div>

<style>
  .qr-error-correction {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
</style>

Images

Link to This Section

Use the image attribute to add a logo or image to the center of the QR code. When using an image, the error correction level will automatically be set to H to ensure the code remains scannable.

<wa-qr-code value="https://webawesome.com/" image="/assets/images/logos/wa-avatar4x.png"></wa-qr-code>

Image Coverage

Link to This Section

Use the image-coverage attribute to control how much of the QR code the image is allowed to cover, from 0 to 1. The default is 0.5.

The higher the image-coverage value, the harder it will be for QR readers to scan. For example, 1.0 usually makes the QR code unreadable.

<div class="qr-ec-cover">
  <wa-qr-code
    value="https://fontawesome.com/"
    image="/assets/images/logos/fa-avatar4x.png"
    image-coverage="0.3"
  ></wa-qr-code>
  <wa-qr-code
    value="https://webawesome.com/"
    image="/assets/images/logos/wa-avatar4x.png"
    image-coverage="0.6"
  ></wa-qr-code>
  <wa-qr-code
    value="https://build.awesome.me/"
    image="/assets/images/logos/ba-avatar4x.png"
    image-coverage="0.9"
  ></wa-qr-code>
</div>

<style>
  .qr-ec-cover {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
  }
</style>

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/webawesome@0.17.0/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.

Name Description Reflects
background
background
The background color. This can be any valid CSS color or transparent. It cannot be a CSS custom property.
Type string
Default ''
errorCorrection
error-correction
The level of error correction to use. Learn more
Type 'L' | 'M' | 'Q' | 'H'
Default 'H'
fill
fill
The fill color. This can be any valid CSS color, but not a CSS custom property.
Type string
Default ''
label
label
The label for assistive devices to announce. If unspecified, the value will be used instead.
Type string
Default ''
radius
radius
The edge radius of each module. Must be between 0 and 0.5.
Type number
Default 0
size
size
The size of the QR code, in pixels.
Type number
Default 128
value
value
The QR code's value.
Type string
Default ''

CSS Parts

Link to This Section

Learn more about CSS parts.

Name Description CSS selector
base The component's base wrapper. ::part(base)
Need a hand? Report a bug Ask for help
Go Make Something Awesome
Version 0.17.0 © Fonticons, Inc.
  • Terms
  • Privacy
  • Refunds
  • Core License
  • Pro License

Quick Links

  • Components
  • CSS Utilities
  • Theming
  • Using with AI
  • Changelog
  • Help & Support

Recent Searches

    D'oh! No results for “”

    Suggest on GitHub Ask on Discord
    Navigate Select
    Close Esc