Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ngx-qrcode-svg

katharinakoal242MIT2.0.0TypeScript support: included

Angular component library to generate QR codes with SVG rendering

qr, code, ngx-qrcode, qrcode, qr-code, angular, angular8, angular9, ng, ngx, svg, generator

readme

CI/CD codecov MIT commitizen PRs styled with prettier semantic-release npm

ngx-qrcode-svg

Angular component library to generate QR codes with SVG rendering.

Table of Contents

Features

  • Scalable high-quality QR code rendering
  • Responsive layout fills the containing element
  • Customizable with plain css or CSS Color Values

Quick example

<qrcode-svg value="The content you want show as QR code"></qrcode-svg>

Demo

See running demo here

Installation

To install ngx-qrcode-svg run the following command:

npm i ngx-qrcode-svg
# Or if you use yarn
yarn add ngx-qrcode-svg

Usage

First, import the QRCodeSVGModule into your consuming module, e.g. into the AppModule

import { QRCodeSVGModule } from 'ngx-qrcode-svg';
...

@NgModule({
    ...
    imports: [ QRCodeSVGModule ],
    ...
})

Then you can use the qrcode-svg tag in your component templates like this:

<qrcode-svg
  [value]="qrCodeValue"
  [errorCorrectionLevel]="errorCorrectionLevel"
  [margin]="margin"
  [color]="color"
  [backgroundColor]="backgroundColor"
></qrcode-svg>

Bindings

The qrcode-svg component supports the following bindings:

  • value: string (required)
    • the content you want to display as QR code
  • errorCorrectionLevel: string (optional, default: 'Q')
    • error correction capability controls the amount of redundant information to restore data if the code is dirty or damaged
    • Valid values: 'L', 'M', 'Q', 'H'
    • If you need the type you can
      import { ErrorCorrectionLevel } from 'ngx-qrcode-svg';
  • margin: number | string (optional, default: 4)
    • the margin is a clear area around a symbol where nothing is printed.
  • color: string (optional, default: 'currentcolor')
  • backgroundColor: string (optional, default: 'transparent')

Set colors with plain css

If you don't pass explicit values to the color or backgroundColor inputs of this component, you can style your QR code with regular css like this:

<qrcode-svg class="qrcode" value="The content you want show as QR code"></qrcode-svg>
.qrcode {
  color: black;
  background: white;
}

Credits

This library is based on the node-qrcode package and inspired by the excellent angularx-qrcode library, which I highly recommend if you need other QR code output formats than SVG in your Angular applications.

License

MIT

The word "QR Code" is registered trademark of:
DENSO WAVE INCORPORATED

changelog

2.0.0 (2020-08-07)

Bug Fixes

  • demo: allow CommonJs import of qrcode (44ff882)

Features

  • enable to set colors by css (4157ca2)

BREAKING CHANGES

  • The color default changed from black to currentcolor. The backgroundColor changed from white to transparent.

1.1.4 (2020-06-18)

Bug Fixes

  • update vulnerable dependencies (51b587d)

1.1.3 (2020-05-18)

Bug Fixes

  • declare support for latest angular 8 version (7bf8966)

1.1.2 (2020-04-23)

Bug Fixes

  • update priority of ivy-specific entry-points (e9f88de)

1.1.1 (2020-04-19)

Bug Fixes

  • drop support for older angular versions (b9a2964)

1.1.0 (2020-04-16)

Features

  • lib: support angular v7 and v8 (e10be31)

1.0.2 (2020-04-15)

Bug Fixes

1.0.1 (2020-04-15)

Bug Fixes

1.0.0 (2020-04-15)

Bug Fixes

  • add missing dependency (ba37e11)
  • add missing dependency (8b9bac0)
  • adjust input defaults and typing (e58ac83)
  • adjust input defaults and typing (3af3019)
  • deployment script (964475c)
  • gh-pages deployment (1e7d555)
  • syntax error in ci config (40b691e)
  • syntax error in ci config (8538979)
  • syntax error in ci config (a23db5d)
  • syntax error in ci config (8436ceb)
  • trigger gh-pages build (93967f6)

Features