Skip to main content Sidebar Design tokens Components Layout Style utilities

We’d love to hear from you. Please reach out to us with any questions or inquiries you may have.

You can contact us via e‐mail at placer.coc.reports+contact@gmail.com.

We look forward to hearing from you!

Got it!
Skip to table of contents

The Placer Toolkit alpha has arrived! 🎉
Plenty of changes are coming your way—some big, some breaking, some even nuclear! Beware the changelog…

Bring it on!

    QR Code

    <pc-qr-code> 0.1.0 experimental

    Generate a QR code and render it using the Canvas API.

    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, log into a Wi-Fi network and so on.

    <div class="qr-code-overview">
        <pc-qr-code
            value="https://example.com"
            label="Scan this QR code to visit example.com."
        ></pc-qr-code>
    
        <br />
    
        <pc-input label="Value" maxlength="255" clearable></pc-input>
    </div>
    
    <script>
        const container = document.querySelector(".qr-code-overview");
        const qrCode = container.querySelector("pc-qr-code");
        const input = container.querySelector("pc-input");
    
        customElements.whenDefined("pc-qr-code").then(() => {
            input.value = qrCode.value;
            input.addEventListener("pc-input", () => {
                qrCode.value = input.value;
            });
        });
    </script>
    
    <style>
        .qr-code-overview {
            max-inline-size: 16rem;
        }
    
        .qr-code-overview pc-input {
            margin-block-start: var(--pc-spacing-l);
        }
    </style>
    Code Edit

    Demos#

    Colours#

    Use the fill and background attributes to modify the QR code’s colours. You should always ensure at least a contrast ratio of 4,5∶1 to ensure that QR code scanners read the QR code properly.

    Edit

    Size#

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

    Edit

    Radius#

    Use the radius attribute to round the corners of the QR code data.

    Edit

    Error correction#

    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.

    Edit

    Properties#

    NameDescriptionReflectsDefault
    valueThe QR code’s value.
    Type: string
    ""
    labelA label to use to describe the QR code to assistive devices. If unspecified, the value will be used instead.
    Type: string
    ""
    sizeThe size of the QR code in pixels.
    Type: number
    128
    fillThe QR code’s fill colour. This can be any valid CSS colour value, but not a custom property.
    Type: string
    "black"
    backgroundThe QR code’s background colour. This can be any valid CSS colour value or transparent, but not a custom property.
    Type: string
    "white"
    radiusThe corner radius of each QR code module. Must be a value between 0 and 0,5.
    Type: number
    0
    errorCorrection
    error-correction
    The level of error correction to use.
    Type: "L" | "M" | "Q" | "H"
    "M"
    updateComplete A read‐only promise that resolves when the component has finished updating.

    Learn more about attributes and properties.

    Parts#

    NameDescription
    baseThe component’s base wrapper.

    Learn more about customising CSS parts.

    Importing#

    If you’re using the autoloader or the standard loader, you can skip this section. But if you’re cherry picking, you can use any of the following snippets to import this component.

    CDN (script tag) CDN (import) npm (import)

    To manually import this component from the CDN, copy this code snippet and paste it in your HTML.

    <script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.1/cdn/components/qr-code/qr-code.js"></script>

    To manually import this component from the CDN, copy this code snippet and paste it in your JavaScript file.

    import "https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.1/cdn/components/qr-code/qr-code.js";

    To manually import this component from npm, copy this code snippet and paste it in your JavaScript file.

    import "placer-toolkit/dist/components/qr-code/qr-code.js";