A basic Vue 3 component for rendering QR codes as SVGs. The QR code generation was heavily inspired by this library.
- No additional dependencies
- Small footprint: ~4kB as a gzipped UMD bundle
- Generate QR codes from arbitrary strings
- Customize error correction levels (ECL)
- SVGs can either be rendered as
paths orrects (with additional styling)
npm install -d @vectrex/vue-qrcode
and in your components
@import QrCode from '@vectrex/vue-qrcode'text- The string to encode into the QR code, requiredoptions- The object containing options for the QR code generator, defaults to{ minVersion: 1, maxVersion: 40, mask: -1, boostEcl: true, ecl: 'M' }gutter- The padding between the QR code and the surrounding SVG, defaults to4module-size- The size of each module in the QR code, defaults to10svg-as-path- Iftrue, renders the whole QR code as a single path, otherwise renders each module as a rectangle, defaults totrueclass- the class name to apply to the SVG elementstyle- the inline style to apply to the SVG elementfill,stroke,stroke-width,rx,ry- applied torectelements ifsvg-as-pathisfalse
Version and mask are typically selected automatically depending on the size of the QR code. ecl defaults to M (Medium) and boostEcl is set to true.
- minVersion:
1to40 - maxVersion:
1to40 - mask:
-1(automatic) to7 - ecl:
L,M,Q,H
<qr-code text="Howdy!" /><qr-code text="https://github.com/vectrex/qr-code-generator" /><qr-code text="https://github.com/vectrex/qr-code-generator" :options="{ ecl: 'H' }" />Don't expect proper detection...
<qr-code text="https://github.com/vectrex/qr-code-generator" :svg-as-path="false" class="size-96" :module-size="20" stroke="white" stroke-width="1" fill="#024" rx="2" />