React Fancy QR Code Generator

1.0.4 · active · verified Sun Apr 19

react-fancy-qrcode is a JavaScript library designed for generating highly customizable QR codes within both React (web) and React Native applications. Currently stable at version 1.0.4, it offers extensive styling options including custom dot shapes via `dotRadius` and `dotScale`, linear gradients for both the primary QR code color and position markers, and the ability to embed a logo in the center. Its release cadence appears active, with an initial v1.0.0 production release followed by minor bug fixes, suggesting ongoing development and maintenance. A key differentiator is its comprehensive customization API, providing developers with fine-grained control over the visual presentation of the QR code, making it suitable for applications that require branded or aesthetically unique QR codes beyond standard implementations. It draws inspiration from `react-native-qrcode-svg` but expands significantly on visual flexibility for a wider range of design requirements.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to render a highly customized QR code using the `QRCode` component. It includes custom dot shapes, gradient colors for both the QR code and its position markers, and an embedded logo, illustrating a wide range of available props.

import React from 'react';
import { QRCode } from 'react-fancy-qrcode';
import { View } from 'react-native'; // Use 'div' for web React

// For demonstration purposes, assuming 'fire.png' exists in './assets/'
// In a real application, ensure the image path is correct for your bundler (web) or Metro (React Native).
// Or use a base64 encoded string for the logo prop directly.
const FireImage = require('./assets/fire.png');

function App() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#f0f0f0' }}>
      <QRCode
        value={"https://checklist.day/package/react-fancy-qrcode?utm_source=demo"}
        size={300}
        dotScale={0.75}
        dotRadius="40%"
        positionRadius={["6%", "2%"]}
        errorCorrection="H"
        logo={FireImage}
        logoSize={60} // Explicitly set to avoid obscuring too much data
        backgroundColor="white"
        color={["#00008b", "#4169e1"]} // Example: Navy to Royal Blue linear gradient
        colorGradientDirection={['0%', '0%', '100%', '100%']}
        positionColor={["#8b0000", "#dc143c"]} // Example: Dark Red to Crimson linear gradient
        positionGradientDirection={['0%', '100%', '100%', '0%']}
        margin={10}
      />
    </View>
  );
}

export default App;

view raw JSON →