npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@acutenetwork/fey2

v1.9.3

Published

Add a style and an image to your QR code

Readme

QR Code Styling

JavaScript library for generating styled QR codes with a wide range of customization options. Works in the browser, Node.js, and React Native.

Features

  • 6 dot styles: square, dots, rounded, extra-rounded, classy, classy-rounded
  • 3 corner square styles: dot, square, extra-rounded
  • 2 corner dot styles: dot, square
  • Linear and radial gradients for all elements
  • Center image overlay with auto-sizing
  • Circle-shaped QR codes
  • SVG and Canvas rendering (web)
  • React Native support via react-native-svg

Installation

npm install qr-code-styling

React Native additional dependencies

npm install react-native-svg

Usage

Browser / Web

import QRCodeStyling from "qr-code-styling";

const qrCode = new QRCodeStyling({
  width: 300,
  height: 300,
  data: "https://example.com",
  image: "https://example.com/logo.png",
  dotsOptions: {
    color: "#4267b2",
    type: "rounded"
  },
  cornersSquareOptions: {
    type: "extra-rounded"
  },
  backgroundOptions: {
    color: "#e9ebee"
  }
});

qrCode.append(document.getElementById("canvas"));

// Download as file
qrCode.download({ name: "qr", extension: "svg" });

React

import { useEffect, useRef } from "react";
import QRCodeStyling from "qr-code-styling";

const qrCode = new QRCodeStyling({
  width: 300,
  height: 300,
  data: "https://example.com",
  dotsOptions: {
    color: "#4267b2",
    type: "rounded"
  }
});

function App() {
  const ref = useRef(null);

  useEffect(() => {
    qrCode.append(ref.current);
  }, []);

  return <div ref={ref} />;
}

React Native

Both named and default imports work:

// Named import
import { QRCodeStylingNative } from "qr-code-styling";

// Or default import
import QRCodeStylingNative from "qr-code-styling";
import { QRCodeStylingNative } from "qr-code-styling";

function App() {
  return (
    <QRCodeStylingNative
      options={{
        width: 300,
        height: 300,
        data: "https://example.com",
        image: "https://example.com/logo.png",
        dotsOptions: {
          color: "#4267b2",
          type: "rounded"
        },
        cornersSquareOptions: {
          type: "extra-rounded"
        },
        cornersDotOptions: {
          type: "dot"
        },
        backgroundOptions: {
          color: "#e9ebee"
        }
      }}
    />
  );
}

Exporting in React Native

Use the onReady callback to get access to export helpers:

import { QRCodeStylingNative } from "qr-code-styling";
import { Share } from "react-native";

function App() {
  const handleReady = ({ toDataURL }) => {
    // toDataURL() returns a Promise<string> with a base64 data URI
    toDataURL().then((dataUri) => {
      Share.share({ url: dataUri });
    });
  };

  return (
    <QRCodeStylingNative
      options={{
        width: 300,
        height: 300,
        data: "https://example.com",
        dotsOptions: { type: "dots", color: "#000" }
      }}
      onReady={handleReady}
    />
  );
}

React Native Props

| Prop | Type | Description | |------|------|-------------| | options | Partial<Options> | QR code configuration (same as web, minus nodeCanvas/jsdom) | | onReady | (helpers: { toDataURL: () => Promise<string> }) => void | Called when SVG is rendered with export helpers |

Options

| Property | Type | Default | Description | |----------|------|---------|-------------| | width | number | 300 | Width of the QR code | | height | number | 300 | Height of the QR code | | data | string | "" | The data to encode | | image | string | undefined | URL of center image | | type | "canvas" \| "svg" | "canvas" | Render type (web only) | | shape | "square" \| "circle" | "square" | QR code shape | | margin | number | 0 | Margin around the QR code | | qrOptions | object | | QR generation options | | imageOptions | object | | Center image options | | dotsOptions | object | | Dot styling options | | cornersSquareOptions | object | | Corner square styling | | cornersDotOptions | object | | Corner dot styling | | backgroundOptions | object | | Background styling |

qrOptions

| Property | Type | Default | |----------|------|---------| | typeNumber | 0 - 40 | 0 (auto) | | mode | "Numeric" \| "Alphanumeric" \| "Byte" \| "Kanji" | auto | | errorCorrectionLevel | "L" \| "M" \| "Q" \| "H" | "Q" |

dotsOptions

| Property | Type | Default | |----------|------|---------| | type | "square" \| "dots" \| "rounded" \| "extra-rounded" \| "classy" \| "classy-rounded" | "square" | | color | string | "#000" | | gradient | Gradient | undefined | | roundSize | boolean | true |

cornersSquareOptions

| Property | Type | Default | |----------|------|---------| | type | "dot" \| "square" \| "extra-rounded" | undefined (follows dot type) | | color | string | undefined (follows dot color) | | gradient | Gradient | undefined |

cornersDotOptions

| Property | Type | Default | |----------|------|---------| | type | "dot" \| "square" | undefined (follows dot type) | | color | string | undefined (follows dot color) | | gradient | Gradient | undefined |

imageOptions

| Property | Type | Default | |----------|------|---------| | hideBackgroundDots | boolean | true | | imageSize | number | 0.4 | | margin | number | 0 | | crossOrigin | string | undefined | | saveAsBlob | boolean | true |

backgroundOptions

| Property | Type | Default | |----------|------|---------| | color | string | "#fff" | | gradient | Gradient | undefined | | round | number | 0 |

Gradient

{
  type: "linear" | "radial",
  rotation: number, // in radians
  colorStops: [
    { offset: 0, color: "#000" },
    { offset: 1, color: "#fff" }
  ]
}

API (Web)

append(container: HTMLElement): void

Appends the QR code to a DOM container.

update(options?: Partial<Options>): void

Updates the QR code with new options.

download(options?: { name?: string, extension?: "svg" | "png" | "jpeg" | "webp" }): Promise<void>

Downloads the QR code as a file.

getRawData(extension?: "svg" | "png" | "jpeg" | "webp"): Promise<Blob | Buffer | null>

Returns the raw QR code data.

applyExtension(extension: (svg: SVGElement, options: Options) => void): void

Applies a custom extension function to the SVG element.

License

MIT