Simple QR Code
The most basic usage ofreact-qr-code requires only the value prop:
- Size: 256×256 pixels
- Background color: white (#FFFFFF)
- Foreground color: black (#000000)
- Error correction level: L (Low)
Changing the Value
Thevalue prop accepts any string and can store up to 2,953 characters according to the official QR spec:
UTF-8 and Non-ASCII Text
react-qr-code automatically encodes data in UTF-8 byte mode, ensuring non-ASCII text (Korean, Japanese, emoji) renders and scans correctly:
Basic Customization
Colors
Customize the foreground and background colors usingfgColor and bgColor:
Size
Adjust the size using thesize prop (in pixels):
Error Correction Level
Choose an error correction level based on your needs:Higher error correction levels make QR codes more resilient to damage but increase their complexity.
Complete Example
Here’s a complete example with all basic props:Quiet Zone
If the QR code appears next to dark objects, wrap it in a light-colored container to preserve the ‘quiet zone’ (the required border around QR codes):The quiet zone is essential for QR code scanners to correctly identify and read the code. A minimum of 4 modules (squares) is recommended.