Usage
QRCode encodes a string into a QR code and renders it as an SVG. It has no external
dependencies and works with server-side rendering:
Size
Set size prop to change the width and height of the code:
Colors
Use color prop to change the color of the dark modules and
bg style prop to change the background color.
Keep a high contrast between the two colors so that the code stays scannable:
Error correction level
errorCorrectionLevel prop controls how much of the code can be damaged or covered
while remaining readable, from L (about 7%) to H (about 30%). Higher levels produce
a denser code:
Low (~7%)
Medium (~15%)
Quartile (~25%)
High (~30%)
Capacity
A QR code holds from about 1270 bytes with errorCorrectionLevel="H" to about 2950 bytes
with "L". When the value is longer, QRCode renders an empty code. Use encodeQR to
validate user input, it throws when the value does not fit:
Logo
Pass any React node to the logo prop to display it in the center of the code.
The logo covers a part of the code, set errorCorrectionLevel="H" to keep it scannable:
Custom rendering with encodeQR
To fully control the appearance, for example to render rounded dots or export to canvas,
use encodeQR function to get the module matrix and render it yourself:
The three large squares in the corners and the alignment patterns must stay solid squares, other modules can have any shape:
Accessibility
By default, aria-label of the code is the encoded value. Set aria-label
or aria-labelledby prop to provide a more descriptive name:
To hide a decorative code that is duplicated by nearby text, use attributes prop
of the Styles API: