Skip to content

Usage

Basic Usage

Render a vector SVG QR code by passing value and size:

BasicQRCodeExample.tsx
import React from 'react';
import { QRCode } from '@masumdev/rn-qr-code';
export function BasicQRCodeExample() {
return (
<QRCode
value="https://react-native-library-docs.netlify.app/rn-qr-code/"
size={200}
variant="BASIC"
/>
);
}

Preset Design Variants

Use the variant prop to apply pre-configured design styles:

PresetVariantsExample.tsx
import React from 'react';
import { QRCode } from '@masumdev/rn-qr-code';
export function PresetVariantsExample() {
return (
<>
{/* Heart preset variant */}
<QRCode value="Love QR" size={180} variant="HEART" />
{/* Linear Gradient preset variant */}
<QRCode value="Gradients" size={180} variant="LINEAR_GRADIENT" />
{/* Triangle preset variant */}
<QRCode value="Triangle" size={140} variant="TRIANGLE" />
</>
);
}

Non-Blocking Async Rendering

Set isAsync to generate the QR matrix off the synchronous render path, preventing UI frame drops during screen transitions:

AsyncQRCodeExample.tsx
import React from 'react';
import { QRCode } from '@masumdev/rn-qr-code';
import { Skeleton } from '@masumdev/rn-ui';
export function AsyncQRCodeExample() {
return (
<QRCode
value="https://react-native-library-docs.netlify.app/rn-qr-code/"
size={180}
isAsync
renderLoading={() => (
<Skeleton style={{ width: 180, height: 180 }} radius="md" />
)}
/>
);
}

Props API

PropTypeDefaultDescription
valuestringPayload text or URL encoded in the QR code.
sizenumber250Width and height of the rendered SVG container in dp.
variantkeyof typeof QR_CODE_CONFIGS'BASIC'Pre-configured design preset key from QR_CODE_CONFIGS.
colorstring'#000000'Primary foreground color for cells.
backgroundColorstring'transparent'Background canvas color.
piece{ shape?: "square" | "dot" | "rounded" | "heart" | "triangle" | "rain"; color?: string; size?: number; borderRadius?: number }Options for individual data module cells.
eyePartial<{ topLeft: EyeOptions; topRight: EyeOptions; bottomLeft: EyeOptions }>Shape, color, and size overrides for 3 corner eye patterns.
logoLogoOptionsCenter logo image source, size ratio (0.0-1.0), padding, and background color.
gradientQRCodeGradientConfigLinear or radial gradient config with color stops and mask options.
imageClipImagePropsImage href background clip fill for data modules.
isAsyncbooleanfalseEnables non-blocking asynchronous calculation using setTimeout(..., 0).
errorCorrectionLevel'L' | 'M' | 'Q' | 'H''M'QR error correction level (Level H recommended when using center logos).
isLoadingbooleanfalseDisplays the loading placeholder view.
renderLoading() => ReactNodeCustom loading placeholder component renderer.