React Native · Components
QRCode
Draws text or an address as a QR code.
4 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Import
QRCode
componentDraws text or an address as a QR code. The encoder is the same as web (@yasinsensoy/core/qr), with no external package; drawing is done with our own native view. The module size is rounded to screen pixels, so no thin lines remain between modules.
Examples
QRErrorLevel
typeError correction level: how much of the code can be damaged and still be read.
L: ~7% (densest, smallest code)M: ~15% (general use)Q: ~25%H: ~30% (when a logo goes in the middle)
QRCodeProps
interfaceProps of QRCode.
| Name | Type | Default | Description |
|---|---|---|---|
value | string | Text or address to encode. | |
level? | QRErrorLevel | "M"`, `"H"` when `image` is given | Error correction level. |
size? | number | 160 | Width and height (px). |
margin? | number | 2 | Quiet zone around the code (modules). At least 2–4 is recommended for readers. |
shape? | QRCodeStyle | "square" | Module shape: square, rounded, dots. |
color? | string | "#000"`, the theme text color when `background="transparent" | Color of the dark modules. With a background the default is black; it is not bound to the theme text color, so the code reads in every theme. On a transparent background, the theme text color. |
background? | string | "#fff" | Background color. "transparent" leaves it transparent. |
image? | string | ImageSourcePropType | Logo to place in the center: an address or require("./logo.png"). The modules behind it are cleared; the level becomes "H" automatically. | |
imageSize? | number | 0.22 | Side length of the logo, as a fraction of the code (0–0.3). |
label? | string | value | Screen reader name. |
minVersion? | EncodeQROptions["minVersion"] | Minimum version (1–40); to fix the code's size. | |
style? | StyleProp<ViewStyle> | Container style. |
QRCodeStyle
typeShape of the modules (squares).
square: classic squares; the most compatible with every reader.rounded: squares with softened corners, finders with rounded corners.dots: dots and round finders.