3.1.0 • Published 2 years ago

qrcode.react v3.1.0

Weekly downloads
277,186
License
ISC
Repository
github
Last release
2 years ago

qrcode.react

A React component to generate QR codes for rendering to the DOM.

Installation

npm install qrcode.react

Usage

qrcode.react exports three components, supporting rendering as SVG or Canvas. SVG is generally recommended as it is more flexible, but Canvas may be preferable.

All examples are shown using modern JavaScript modules and syntax. CommonJS require('qrcode.react') is also supported.

QRCodeSVG

import ReactDOM from 'react-dom';
import {QRCodeSVG} from 'qrcode.react';

ReactDOM.render(
  <QRCodeSVG value="https://reactjs.org/" />,
  document.getElementById('mountNode')
);

QRCodeCanvas

import ReactDOM from 'react-dom';
import {QRCodeCanvas} from 'qrcode.react';

ReactDOM.render(
  <QRCodeCanvas value="https://reactjs.org/" />,
  document.getElementById('mountNode')
);

QRCode - DEPRECATED

Note: Usage of this is deprecated as of v3. It is available as the default export for compatiblity with previous versions. The renderAs prop is only supported with this component.

import ReactDOM from 'react-dom';
import QRCode from 'qrcode.react';

ReactDOM.render(
  <QRCode value="https://reactjs.org/" renderAs="canvas" />,
  document.getElementById('mountNode')
);

Available Props

proptypedefault value
valuestring
renderAsstring ('canvas' 'svg')'canvas'
sizenumber128
bgColorstring (CSS color)"#FFFFFF"
fgColorstring (CSS color)"#000000"
levelstring ('L' 'M' 'Q' 'H')'L'
includeMarginbooleanfalse
imageSettingsobject (see below)

imageSettings

fieldtypedefault value
srcstring
xnumbernone, will center
ynumbernone, will center
heightnumber10% of size
widthnumber10% of size
excavatebooleanfalse

Custom Styles

qrcode.react 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>.

Encoding Mode

qrcode.react supports encoding text only, in a single segment. The encoding library being used does minimal detection to determine if the text being encoded can follow an optimized path for Numeric or Alphanumeric modes, allowing for more data to be encoded. Otherwise, it will encode following Byte mode. This mode includes supports multi-byte Unicode characters such as Kanji, however it does not support the optimized Kanji encoding mode.

LICENSE

qrcode.react is licensed under the ISC license.

qrcode.react bundles QR Code Generator, which is available under the MIT license.

@zelty/ui-kit-order@poofcash/use-contractkitdci-webuidaas-print-lib@blockbolt/boltpay-sui-client@clerk/clerk-jsaws-amplify-reactamerican-golf-kioskzwap-qrcode-frontendcf-storybookbob-walletkryptokrona-desktop-walletbooksopen_web_componentswps-driver-react@identance/sdkbitcasino-v3voltsdksimple-widget@joseirrazabal/linkscrypticcoin-walletcrypticcoin-wallet-testverify-modal-twopds-dev-kitargent-connect-reactgold-claimlisqvizesmile-xin-amis@elijahjpassmore/qwc2fastamiscybex-game-addon@map3xyz/client-deposit-sdk@map3xyz/payments-sdkobyte-qr-button-test21@infinitebrahmanuniverse/nolb-qrcff-uixdcorerussia-warrect-components-007@everything-registry/sub-chunk-2510react-components-007datav-amisintelligent-designduck-mediahc-lc-components-lib@arconnect/keystone-sdk@artid/azwallet-kit@arcblock/did-react@arcblock/react-forge@arcblock/ux@apmp/plugin-intl-auth@authing/guard-core@authing/guard-core-v4@authing/guard-core-v6@automattic/jetpack-components@axa-ch/pod-ahv-easy@alicloud/console-base-risk-prompt@aliretail/react-oms-merchants-sdk@aligov/components@aliyun-sls/dashboard@baic/yolk-mobile-ui@baic/yolk-web-ui@beisen-oneops/amis@bcpros/lixi-components@celo-tools/use-contractkit@baic/yolk-mobile@botonic/react@brianli/use-contractkit@binance-chain/honeycomb@binance/w3w-qrcode-modalbedips-toolsbch-wallet-plugin-boilerplate@bty/chat-ui-mobile@brulogaz/aws-amplify-react@brilliant_emporium/ui@btcinc/react-webln-fallback-antd@chipunderblade/amis@cheqd/wallet@chainapsis/cosmodalbitcoin-invoice-components@chalabi/cosmoskit-template@cscec/udp-antd-basebrightid@cogitojs/cogito-react-ui@coindirect/payments@coinmasters/pioneer@coinmasters/pioneer-lib@connext/vector-modalbotonic-react@citydna/experience@cubitrix/cubitrix-react-ui-modulecycurid-oauth2-clientdapp-nextdal-use-contractkitdg-modal-widgetcz-common-uidadada111decorate-v2dicc-antddiva-reactdebug-eth-contract
3.0.2

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.0

6 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.2

8 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago