Skip to main content

API Reference

QRCode Component

Component Configuration

The QRCode component provides a highly customizable interface for generating QR codes with various styles and configurations.

QRCodeProps

Core properties for customizing the QR code appearance and behavior.

PropTypeDefaultDescription
valuestring-The content to be encoded in the QR code. Can be any text, URL, or data string.
variantQRCodeVariant'BASIC'The design variant of the QR code. Choose from predefined templates.
sizenumber256The size of the QR code in pixels. Determines both width and height.
colorstring'#000'The main color of the QR code elements. Accepts any valid CSS color value.
backgroundColorstring'transparent'The background color behind the QR code. Set to 'transparent' for no background.
gradientQRCodeGradientConfig-Advanced gradient configuration for creating beautiful color transitions.
logoLogoOptions-Options for adding a centered logo image with customizable size and styling.
piecePieceOptions-Customize the shape and style of individual QR code elements.
eyeEyeOptions-Style the three corner finder patterns (eyes) of the QR code.
includeBackgroundbooleanfalseWhen true, adds a wrapper background element behind the QR code.
versionQRCodeVersion-Set a specific QR code version (1-40). Higher versions can store more data.
maxVersionQRCodeVersion-The maximum allowed QR code version. Useful for limiting complexity.
imageClipImageProps-Props for adding an image as a clip mask to the QR code pattern, SVG Props
errorCorrectionLevelQRCodeErrorCorrectionLevel'M'Error correction capability: L (7%), M (15%), Q (25%), or H (30%).

QRCodeVariant

Choose from a range of predefined templates to quickly style your QR code.

ValueDescriptionVisual Effect
'BASIC'Simple, basic QR codeMinimalistic, clean
'TRIANGLE'Triangle-shaped QR codeTriangular, elegant
'HEART'Heart-shaped QR codeHearty, romantic
'DOT'Dotted QR code patternModern, minimalist
'WITH_LOGO'QR code with centered logoProfessional, branded
'RAIN'Rainy QR code with falling piecesRainy, atmospheric
'LINEAR_GRADIENT'Linear gradient colored QR codeSmooth, colorful
'RADIAL_GRADIENT'Radial gradient colored QR codeDynamic, radiant
'IMAGE_BACKGROUND'QR code with image backgroundCreative, unique

QRCodeGradientConfig

Create beautiful gradient effects for your QR code with these advanced configuration options.

PropTypeDefaultDescription
type'linear' | 'radial''linear'Choose between linear (straight line) or radial (circular) gradient patterns
maskLogobooleanfalseWhen true, prevents the gradient from overlaying the logo area
directionGradientDirection'to-right'Sets the flow direction for linear gradients (see GradientDirection below)
colorsGradientColor[]-Define multiple color stops with position and opacity for smooth transitions
cxstring'50%'Center X position of radial gradient (e.g. '50%' for middle)
cystring'50%'Center Y position of radial gradient (e.g. '50%' for middle)
rstring'50%'Radius of the radial gradient (e.g. '50%' for half of QR code size)
fxstring-Focal point X position for radial gradient (creates elliptical effects)
fystring-Focal point Y position for radial gradient (creates elliptical effects)
x1string'0%'Starting X position for linear gradient (e.g. '0%' for left edge)
y1string'0%'Starting Y position for linear gradient (e.g. '0%' for top edge)
x2string'100%'Ending X position for linear gradient (e.g. '100%' for right edge)
y2string'0%'Ending Y position for linear gradient (e.g. '0%' for top edge)

GradientDirection

Specify the flow direction of linear gradients. This setting creates dynamic and visually appealing QR codes.

ValueDescriptionVisual Effect
'to-right'Gradient flows from left to rightHorizontal transition →
'to-left'Gradient flows from right to leftHorizontal transition ←
'to-bottom'Gradient flows from top to bottomVertical transition ↓
'to-top'Gradient flows from bottom to topVertical transition ↑
'to-bottom-right'Gradient flows diagonally from top-left to bottom-rightDiagonal transition ↘
'to-bottom-left'Gradient flows diagonally from top-right to bottom-leftDiagonal transition ↙
'to-top-right'Gradient flows diagonally from bottom-left to top-rightDiagonal transition ↗
'to-top-left'Gradient flows diagonally from bottom-right to top-leftDiagonal transition ↖

GradientColor

Define smooth color transitions by specifying multiple color stops in your gradient. Each stop controls position, color, and transparency.

PropTypeDescriptionExample
offsetstringPosition of the color stop along the gradient (0-100%)'0%' for start, '50%' for middle, '100%' for end
colorstringAny valid color value (hex, rgb, named colors)'#FF5733', 'rgb(255,87,51)', 'coral'
opacitynumberTransparency level between 0 (invisible) and 1 (solid)0.8 for 80% opacity

LogoOptions

Customize the appearance of a centered logo within your QR code. The logo can be an image from your local assets or a remote URL.

PropTypeDefaultDescriptionNotes
sourceImageSource-Logo image source (local asset/URL)See ImageSource below for format details
sizenumber20%Logo size as percentage of QR code widthKeep between 10-30% for best scanning
backgroundColorstring'white'Background color behind the logoUse light colors for better contrast
paddingnumber2Space around logo in pixelsHelps logo stand out from QR pattern
borderRadiusnumber0Rounded corners for logo backgroundHigher values create circular shapes

ImageSource

Specify the source of your logo image. The component supports both local project assets and remote image URLs.

TypeDescriptionExampleBest Practices
numberLocal image from project assetsrequire('./assets/logo.png')Use for bundled images
stringRemote image from URL'https://example.com/logo.png'Ensure reliable hosting

Important Guidelines:

  • Local assets: Use require() for images in your project directory
  • Remote URLs: Provide complete HTTPS URLs for security
  • Supported formats: PNG (recommended), JPG, JPEG
  • Optimal size: 50-100 pixels for best balance of clarity and scanning
  • File size: Keep under 50KB to maintain performance

PieceOptions

Customize the appearance of individual QR code elements (the small squares that make up the pattern).

PropTypeDefaultDescriptionVisual Impact
shape'square'|'dot'|'triangle'|'heart'|'rain''square'Shape of each QR code elementChanges overall pattern style
sizenumber1Scale factor for element size (0.5-2.0)Affects density and readability
spacingnumber0Gap between elements in pixelsCreates breathing room in pattern

EyeOptions

Style the three finder patterns (eyes) in the corners of the QR code. These are crucial for scanner orientation.

PropTypeDefaultDescriptionImpact
topLeftEyeShapeConfigStyle for top-left corner patternAffects scanning reliability
topRightEyeShapeConfigStyle for top-right corner patternMust remain distinct
bottomLeftEyeShapeConfigStyle for bottom-left corner patternHelps orientation
EyeShapeConfig

Detailed configuration for each QR code eye (finder pattern).

PropTypeDefaultDescriptionBest Practice
shape'square'|'circle'|'rounded''square'Overall shape of the eye patternKeep distinctive
size{ center: number, inner: number }-Size multiplier for center and inner componentsMaintain proportions
radius{ radiusOuter: number, radiusInner: number, radiusCenter: number }-Corner rounding for each partBalance style with function
colorstring-Main color of the eye patternUse high contrast
innerColorstring-Color of the inner eye componentComplement main color

QRCodeVersion

Control the size and data capacity of your QR code.

TypeDescriptionUse Case
number (1-40)QR code version numberHigher versions = more data, larger size

Version Guide:

  • 1-10: Best for short URLs and text (up to 174 characters)
  • 11-20: Medium content (up to 1,663 characters)
  • 21-40: Large content like vCards or detailed data

ImageProps

Advanced SVG image properties for creating custom QR code patterns.

PropTypeDefaultDescriptionNotes
xnumber-Horizontal position of the imagePosition from left
ynumber-Vertical position of the imagePosition from top
widthnumber-Width of the imageIn pixels or percentage
heightnumber-Height of the imageIn pixels or percentage
xlinkHrefImageSource | string-Source of the image (legacy attribute)Use href instead
hrefImageSource | string-Source of the imagePreferred over xlinkHref
preserveAspectRatiostring-How image should scale (e.g., 'xMidYMid meet')Controls image fitting
opacitynumber1Transparency of the image (0-1)0 = transparent, 1 = solid
onLoadfunction-Callback when image loadsHandles load completion

QRCodeErrorCorrectionLevel

Balance between data redundancy and error correction capability.

LevelError Correction CapacityBest Used For
L~7% damage recoveryClean environments, maximum data capacity
M~15% damage recoveryStandard use, good balance
Q~25% damage recoveryPublic display, some wear expected
H~30% damage recoveryOutdoor use, high reliability needed

QRCodeScanner Component

Scanner Configuration

The QRCodeScanner component offers a feature-rich interface for QR code scanning with customizable UI and behavior.

QRCodeScanner Props

QRCodeScanner component accepts several prop groups that control different aspects of its functionality:

Core Props

PropTypeRequiredDescription
onSuccessfulScan(state: OnSuccessfulScanProps) => voidYesCallback function called when QR code is successfully scanned
validateQRCodeValidatorNoCustom validation function for scanned QR codes

Scanning Props

PropTypeDefaultDescription
cooldownDurationnumber2000Time in milliseconds between scans
scanningAreaScanningAreaProps-Configure the scanning target area
ScanningAreaProps
PropTypeDefaultDescription
targetXnumber-X coordinate of scanning target
targetYnumber-Y coordinate of scanning target
tolerancenumber-Tolerance area around target coordinates

UI Controls Props

PropTypeDefaultDescription
showControlsbooleantrueShow/hide control buttons
showStatusbooleantrueShow/hide status information
showTorchButtonbooleantrueShow/hide torch control button

Appearance Props

PropTypeDefaultDescription
theme'light' | 'dark''light'UI theme selection
overlayStyleOverlayStyle-Customize scanner overlay
frameStyleFrameStyle-Customize scanner frame
cornerStyleCornerStyle-Customize corner markers
controlButtonStyleControlButtonStyle-Customize control buttons
statusStyleStatusStyle-Customize status display
OverlayStyle
PropTypeDescription
backgroundColorstringBackground color of overlay
opacitynumberOpacity level of overlay
FrameStyle
PropTypeDescription
widthnumberWidth of scanning frame
heightnumberHeight of scanning frame
borderRadiusnumberBorder radius of frame corners
CornerStyle
PropTypeDescription
colorstringColor of corner markers
widthnumberWidth of corner lines
lengthnumberLength of corner lines
StatusStyle
PropTypeDescription
backgroundColorstringBackground color of status box
textColorstringColor of status text
borderRadiusnumberBorder radius of status box
paddingnumberPadding inside status box
fontWeightstringFont weight of status text

Callbacks Props

PropTypeDescription
onTorchChange(isOn: boolean) => voidCalled when torch state changes
onScanStart() => voidCalled when scanning starts
onScanEnd() => voidCalled when scanning ends
onCooldownStart(duration: number) => voidCalled when cooldown period starts
onCooldownEnd() => voidCalled when cooldown period ends

Haptics Props

PropTypeDefaultDescription
enableHapticFeedbackbooleantrueEnable/disable haptic feedback
customHapticFeedback{ success?: NotificationFeedbackType; error?: NotificationFeedbackType }-Custom haptic feedback settings
PropTypeDescription
onBackPress() => voidCustom back button handler
showBackButtonbooleanShow/hide back button
backButtonIconstringIcon name for back button

Custom Components Props

PropTypeDescription
renderCustomStatus(statusInfo: StatusInfo) => React.ReactNodeCustom status component renderer
renderCustomControls(controls: ControlsInfo) => React.ReactNodeCustom controls component renderer

Custom Styles Props

PropTypeDescription
containerStyleViewStyleCustom styles for container
statusBoxStyleViewStyleCustom styles for status box
statusTextStyleTextStyleCustom styles for status text