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

react-qr-label

v0.1.1

Published

An embeddable, visual drag-and-drop QR label designer for React. Generate layouts and export to PDF, PNG, and ZPL formats.

Downloads

193

Readme

React QR Label Designer Component (react-qr-label)

A professional, embeddable drag-and-drop QR code & barcode label designer for React. Design custom label templates visually, bind dynamic schema variables, and bulk-print to PDF, PNG, or ZPL (Zebra thermal printers).

npm version npm downloads License: MIT TypeScript


react-qr-label is the official React wrapper for the QRLayout ecosystem. It equips your React applications with an interactive, responsive WYSIWYG editor for designing custom barcode, text, and QR code sticker templates. Users can layout elements, bind dynamic database tags (like {{sku}} or {{price}}), run real-time previews with sample data, and export templates to standard JSON format.

With the companion headless printing engine included in the library, you can merge your JSON templates with live records to generate batch files for standard printing or industrial logistics.

🔗 Key Resources


📖 Table of Contents

  1. Key Features
  2. Installation
  3. Quick Start (Getting Started)
  4. Component Props Reference
  5. Save & Bulk Printing Workflow
  6. Type Definitions (TypeScript)
  7. Industry Use Cases
  8. License

✨ Key Features

  • 🎨 Visual Drag & Drop WYSIWYG Editor: Position, resize, and configure text blocks, barcodes, and QR codes directly on a fluid, adjustable canvas.
  • Dynamic Variables & Data Binding: Inject template tags (e.g. {{fullName}}, {{sku}}, {{price}}) that dynamically resolve during preview and batch print.
  • 🔗 Multi-Field QR Codes: Merge multiple data columns into a single QR scan value with customizable separators (e.g., id|name|dept).
  • 🖨️ Multi-Format Export Engine: Batch print your designs to high-resolution PDF documents, PNG images, or raw ZPL command streams for Zebra industrial thermal printers.
  • 🌓 Integrated Dark Mode: Modern dark mode that adapts to system-level settings automatically or can be toggled via design controls.
  • 🏎️ Performance Optimized: Leverages React ref patterns to prevent canvas re-renders when updating state, protecting history stack and drag positions.
  • 📏 Flexible Dimensioning: Create sticker layouts measured in millimeters (mm), centimeters (cm), inches (in), or pixels (px).

🚀 Installation

Install the package and its peer dependencies via npm, yarn, or pnpm:

npm install react-qr-label

(Note: qrlayout-core and qrlayout-ui are direct dependencies and are installed automatically).


💻 Quick Start (Getting Started)

1. Import Stylesheet

Import the required CSS styles in your entry file (e.g., main.tsx, index.tsx, or App.tsx):

import 'react-qr-label/style.css';

2. Component Integration

Mount the interactive designer in any React page. The canvas container is fluid, adapting to its parent wrapper's width and height.

import { useState } from 'react';
import { QRLabelDesigner, type StickerLayout, type EntitySchema } from 'react-qr-label';
import 'react-qr-label/style.css';

export default function LabelDesignerPage() {
  // Define default starting layout
  const [layout, setLayout] = useState<StickerLayout>({
    id: 'badge-template-1',
    name: 'Standard Employee ID Badge',
    width: 100,
    height: 60,
    unit: 'mm',
    backgroundColor: '#ffffff',
    targetEntity: 'employee',
    elements: []
  });

  // Provide fields available for variables drag-and-drop mapping
  const entitySchemas: Record<string, EntitySchema> = {
    employee: {
      label: 'Employee Database Fields',
      fields: [
        { name: 'fullName', label: 'Full Name' },
        { name: 'employeeId', label: 'Employee ID' },
        { name: 'department', label: 'Department' }
      ],
      sampleData: {
        fullName: 'Jane Doe',
        employeeId: 'EMP-9021',
        department: 'Operations'
      }
    }
  };

  const handleSave = (savedLayout: StickerLayout) => {
    // Persist this JSON configuration object to your backend database
    console.log('Saved Layout Configuration:', savedLayout);
    setLayout(savedLayout);
  };

  return (
    <div style={{ width: '100vw', height: '100vh', position: 'relative' }}>
      <QRLabelDesigner
        initialLayout={layout}
        entitySchemas={entitySchemas}
        onSave={handleSave}
        style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}
      />
    </div>
  );
}

⚙️ Component Props Reference

The <QRLabelDesigner /> component accepts the following props:

| Prop | Type | Required | Default | Description | | :--- | :--- | :---: | :---: | :--- | | initialLayout | StickerLayout | ❌ | undefined | The initial layout template structure JSON to pre-render. | | entitySchemas | Record<string, EntitySchema> | ❌ | undefined | Available entity data structures, showing autocomplete variables and mapping test-data. | | onSave | (layout: StickerLayout) => void | ❌ | undefined | Callback function fired when the user triggers the "Save Layout" button in the toolbar. | | className | string | ❌ | undefined | Optional class applied to the designer outer container. | | style | React.CSSProperties | ❌ | { width: '100%', height: '100%' } | Custom style specifications for the designer wrapper. |


💾 Save & Bulk Printing Workflow

The WYSIWYG editor produces a lightweight, database-friendly JSON layout object. To perform bulk-printing or document assembly (mail-merge style) on your database records, use the headless StickerPrinter engine or PDF modules:

import { StickerPrinter } from 'react-qr-label';

Bulk Export to PDF

Generate print-ready multi-page PDF documents.

[!NOTE] PDF generation requires the peer library jspdf. Please install it in your project: npm install jspdf.

Option A: Using the StickerPrinter class:

import { StickerPrinter } from 'react-qr-label';

const printer = new StickerPrinter();
const pdf = await printer.exportToPDF(layoutJSON, databaseRecords);
pdf.save('bulk-labels.pdf');

Option B: Importing the utility sub-path directly:

import { exportToPDF } from 'react-qr-label/pdf';

const pdf = await exportToPDF(layoutJSON, databaseRecords);
pdf.save('bulk-labels.pdf');

Bulk Export to ZPL (Thermal Printing)

For industrial applications, Zebra thermal printers (and other ZPL-compatible devices) can print layouts at high speeds without standard printer drivers. You can export layout templates directly to raw ZPL instructions:

import { StickerPrinter } from 'react-qr-label';

const printer = new StickerPrinter();

// Export layout configuration combined with dynamic array data
const zplPages = printer.exportToZPL(layoutJSON, databaseRecords, { dpi: 203 });

// Join all label pages into a single print job command string
const rawPrintJob = zplPages.join('\n');

// Send rawPrintJob straight to the thermal printer socket (typically port 9100)

📦 Type Definitions (TypeScript)

Full TypeScript typings are exported out of the box to support type safety:

export interface StickerLayout {
  id: string;
  name: string;
  width: number;
  height: number;
  unit: 'mm' | 'cm' | 'in' | 'px';
  backgroundColor?: string;
  targetEntity?: string;
  elements: StickerElement[];
}

export interface StickerElement {
  id: string;
  type: 'text' | 'qr';
  x: number;
  y: number;
  w: number;
  h: number;
  content: string;
  qrSeparator?: string;
  style?: {
    fontSize?: number;
    fontWeight?: 'normal' | 'bold';
    textAlign?: 'left' | 'center' | 'right';
    verticalAlign?: 'top' | 'middle' | 'bottom';
  };
}

export interface EntityField {
  name: string;
  label: string;
}

export interface EntitySchema {
  label: string;
  fields: EntityField[];
  sampleData: Record<string, any>;
}

🎯 Industry Use Cases

  • 🏭 Warehousing & Shipping Labels: Generate ZPL layouts for Zebra printers to output thermal stickers for packages, boxes, and warehouse bins.
  • 🏷️ Retail SKU Price Tags: Build compact price tags containing dynamic item details, barcoded prices, and discount percentages.
  • 🎟️ Event Attendance & Visitor Badges: Design employee identity passes and attendee badges dynamically mapped to registration databases.
  • 🔧 Asset & Hardware Inspection Tags: Generate weather-resistant asset tags equipped with QR codes pointing to online maintenance manuals.

📄 License

MIT © Shashidhar Naik