devmehq/react-qr-code

Repository files navigation

Simple & Advanced React component to generate QR codes

NPM versionBuild StatusDownloadsUNPKG

Edit react-qr-code-demo

npm install @devmehq/react-qr-code
yarn install @devmehq/react-qr-code
import React from 'react';
import { ReactQrCode } from '@devmehq/react-qr-code';

<ReactQrCode value="http://facebook..io/react/" />
var React = require('react');
var { ReactQrCode } = require('@devmehq/react-qr-code');

<ReactQrCode value="http://facebook..io/react/" />
proptypedefault value
valuestring
renderAsstring ('canvas' 'svg')'canvas'
sizenumber128
bgColorstring (CSS color)"#FFFFFF"
fgColorstring (CSS color)"#000000"
levelstring ('L' 'M' 'Q' 'H')'L'
marginSizenumberfalse
imagesarray (see below)
fieldtypedefault value
srcstring
xnumbernone, will center
ynumbernone, will center
heightnumber10% of size
widthnumber10% of size
excavatebooleanfalse

@devmehq/react-qr-code will pass through any additional props to the underlying DOM node (<svg> or <canvas>). This allows the use of inline style or custom className to customize the rendering. One common use would be to support a responsive layout.

Note: In order to render QR Codes in <canvas> on high density displays, we scale the canvas element to contain an appropriate number of pixels and then use inline styles to scale back down. We will merge any additional styles, with custom height and width overriding our own values. This allows scaling to percentages but if scaling beyond the size, you will encounter blurry images. I recommend detecting resizes with something like react-measure to detect and pass the appropriate size when rendering to <canvas>.

qrcode-demo

  • Add Image Ref
  • Add Corner Images and Center Image
  • Add Examples to wifi password, 2fa, and other QR codes
  • ADD SSR Rendering Support
  • Add Download / Share QR Code
  • Add Test

About

A QRCode React Component ( SVG / Canvas )

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5