Implementing Syncfusion React Barcode
When to Use This Skill
Use this skill when you need to:
- Generate barcodes (Code39, Code128, Code11, Code32, Code93, Codabar) in React
- Create QR codes for URLs, contact info, or product identification
- Generate Data Matrix codes for labels, tracking, or inventory
- Customize barcode appearance (size, color, text display)
- Export barcodes as images (JPG, PNG) or base64 strings
- Integrate barcode generation into forms, reports, or applications
Library Overview: Three Generator Types
Syncfusion React Barcode provides three main components:
BarcodeGeneratorComponent - Traditional 1D barcodes (Code39, Code128, etc.)
- Character encoding varies by type
- Ideal for: Product codes, inventory, retail
- Readability: High, works with basic scanners
QRCodeGeneratorComponent - 2D Quick Response codes
- Versions 1-40 with automatic scaling
- Ideal for: URLs, contact info, product links, advertising
- Capacity: Up to thousands of characters
DataMatrixGeneratorComponent - 2D Data Matrix codes
- Square/rectangular format, compact size
- Ideal for: Labels, parts tracking, aerospace/automotive
- Capacity: Alphanumeric data, efficient encoding
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installation and dependencies
- Vite/React setup
- Component imports and basic structure
- Parent component initialization
Barcode Generator Types
📄 Read: references/barcode-generator.md
- Code39, Code39Extended, Code11, Code128, Code32, Code93, Codabar
- When to use each type
- Character set support per type
- Encoding and checksum information
- Implementation examples for each
QR Code Generator
📄 Read: references/qr-code-generator.md
- QR Code basics and versions
- Automatic version selection
- Character encoding (numeric, alphanumeric, JIS8)
- Common use cases and patterns
- Implementation with different data types
Data Matrix Generator
📄 Read: references/data-matrix-generator.md
- Data Matrix basics and structure
- Encoding rules and character support
- Size and capacity considerations
- Label and printing applications
- Comparison with other barcode types
Customization and Styling
📄 Read: references/customization.md
- Barcode dimensions (width, height)
- Colors (foreColor, backgroundColor)
- Display text customization
- Examples of size and color variations
- Responsive design patterns
Export and Integration
📄 Read: references/export-and-integration.md
- Export as image (JPG, PNG)
- Export as base64 string
- Method: exportImage(filename, format)
- Method: exportAsBase64Image(format)
- Integration with forms, APIs, and reports
Quick Start Examples
Code39 Barcode
import React from 'react';
import { BarcodeGeneratorComponent } from '@syncfusion/ej2-react-barcode-generator';
export default function App() {
return (
<BarcodeGeneratorComponent
id="barcode"
type="Code39"
value="SYNCFUSION"
width="200px"
height="150px"
/>
);
}
QR Code
import React from 'react';
import { QRCodeGeneratorComponent } from '@syncfusion/ej2-react-barcode-generator';
export default function App() {
return (
<QRCodeGeneratorComponent
id="qrcode"
value="https://www.syncfusion.com"
width="200px"
height="200px"
/>
);
}
Data Matrix
import React from 'react';
import { DataMatrixGeneratorComponent } from '@syncfusion/ej2-react-barcode-generator';
export default function App() {
return (
<DataMatrixGeneratorComponent
id="datamatrix"
value="Syncfusion"
width="200px"
height="200px"
/>
);
}
Common Patterns
Pattern 1: Dynamic Value Generation
const [barcodeValue, setBarcodeValue] = React.useState('DEFAULT123');
<BarcodeGeneratorComponent
type="Code128"
value={barcodeValue}
width="200px"
height="150px"
/>
Pattern 2: Export on Button Click
const barcodeRef = React.useRef();
const handleExport = () => {
barcodeRef.current.exportImage('barcode', 'PNG');
};
<div>
<BarcodeGeneratorComponent
ref={barcodeRef}
type="Code39"
value="SYNC123"
width="200px"
height="150px"
/>
<button Barcode</button>
</div>
Pattern 3: Styled Container
<div style={{ padding: '20px', border: '1px solid #ddd' }}>
<QRCodeGeneratorComponent
value="https://example.com"
width="250px"
height="250px"
foreColor="#333"
backgroundColor="#fff"
/>
</div>
Key Props
| Prop |
Description |
Used By |
type |
Barcode type (Code39, Code128, Code11, Code32, Code93, Codabar) |
BarcodeGeneratorComponent |
value |
Data to encode |
All generators |
width |
Barcode width (string with px) |
All generators |
height |
Barcode height (string with px) |
All generators |
foreColor |
Dark/bar color |
All generators |
backgroundColor |
Light/space color |
All generators |
displayText |
Object to customize display text |
All generators |
id |
Unique component identifier (required for export) |
All generators |
Common Use Cases
- Retail & Inventory: Code128 barcodes for products and SKUs
- E-commerce: QR codes linking to product pages or reviews
- Logistics: Data Matrix for package tracking and labels
- Document Management: QR codes embedding document metadata
- Marketing: Dynamic QR codes with analytics
- Healthcare: Code128/Code39 for specimen/patient labeling
- Form Workflows: Export barcodes for printing or archival
Next Steps
- Choose your generator type based on use case
- Read the getting started guide
- Review the specific generator documentation
- Customize appearance as needed
- Implement export if required for your workflow
1---
2name: syncfusion-react-barcode
3description: "Generate, customize, and export barcodes in React using Syncfusion BarcodeGenerator. Trigger for requests involving Code39 or Code128 barcodes, QR codes, Data Matrix generation, barcode styling (size, color, text, margins), React component setup, props or events, SVG or canvas rendering, and exporting or printing barcode images."
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7 category: "Data Visualization"
8---
9
10# Implementing Syncfusion React Barcode
11
12## When to Use This Skill
13
14Use this skill when you need to:
15- Generate barcodes (Code39, Code128, Code11, Code32, Code93, Codabar) in React
16- Create QR codes for URLs, contact info, or product identification
17- Generate Data Matrix codes for labels, tracking, or inventory
18- Customize barcode appearance (size, color, text display)
19- Export barcodes as images (JPG, PNG) or base64 strings
20- Integrate barcode generation into forms, reports, or applications
21
22## Library Overview: Three Generator Types
23
24Syncfusion React Barcode provides three main components:
25
261. **BarcodeGeneratorComponent** - Traditional 1D barcodes (Code39, Code128, etc.)
27 - Character encoding varies by type
28 - Ideal for: Product codes, inventory, retail
29 - Readability: High, works with basic scanners
30
312. **QRCodeGeneratorComponent** - 2D Quick Response codes
32 - Versions 1-40 with automatic scaling
33 - Ideal for: URLs, contact info, product links, advertising
34 - Capacity: Up to thousands of characters
35
363. **DataMatrixGeneratorComponent** - 2D Data Matrix codes
37 - Square/rectangular format, compact size
38 - Ideal for: Labels, parts tracking, aerospace/automotive
39 - Capacity: Alphanumeric data, efficient encoding
40
41## Documentation and Navigation Guide
42
43### Getting Started
44📄 **Read:** [references/getting-started.md](references/getting-started.md)
45- Installation and dependencies
46- Vite/React setup
47- Component imports and basic structure
48- Parent component initialization
49
50### Barcode Generator Types
51📄 **Read:** [references/barcode-generator.md](references/barcode-generator.md)
52- Code39, Code39Extended, Code11, Code128, Code32, Code93, Codabar
53- When to use each type
54- Character set support per type
55- Encoding and checksum information
56- Implementation examples for each
57
58### QR Code Generator
59📄 **Read:** [references/qr-code-generator.md](references/qr-code-generator.md)
60- QR Code basics and versions
61- Automatic version selection
62- Character encoding (numeric, alphanumeric, JIS8)
63- Common use cases and patterns
64- Implementation with different data types
65
66### Data Matrix Generator
67📄 **Read:** [references/data-matrix-generator.md](references/data-matrix-generator.md)
68- Data Matrix basics and structure
69- Encoding rules and character support
70- Size and capacity considerations
71- Label and printing applications
72- Comparison with other barcode types
73
74### Customization and Styling
75📄 **Read:** [references/customization.md](references/customization.md)
76- Barcode dimensions (width, height)
77- Colors (foreColor, backgroundColor)
78- Display text customization
79- Examples of size and color variations
80- Responsive design patterns
81
82### Export and Integration
83📄 **Read:** [references/export-and-integration.md](references/export-and-integration.md)
84- Export as image (JPG, PNG)
85- Export as base64 string
86- Method: exportImage(filename, format)
87- Method: exportAsBase64Image(format)
88- Integration with forms, APIs, and reports
89
90## Quick Start Examples
91
92### Code39 Barcode
93```tsx
94import React from 'react';
95import { BarcodeGeneratorComponent } from '@syncfusion/ej2-react-barcode-generator';
96
97export default function App() {
98 return (
99 <BarcodeGeneratorComponent
100 id="barcode"
101 type="Code39"
102 value="SYNCFUSION"
103 width="200px"
104 height="150px"
105 />
106 );
107}
108```
109
110### QR Code
111```tsx
112import React from 'react';
113import { QRCodeGeneratorComponent } from '@syncfusion/ej2-react-barcode-generator';
114
115export default function App() {
116 return (
117 <QRCodeGeneratorComponent
118 id="qrcode"
119 value="https://www.syncfusion.com"
120 width="200px"
121 height="200px"
122 />
123 );
124}
125```
126
127### Data Matrix
128```tsx
129import React from 'react';
130import { DataMatrixGeneratorComponent } from '@syncfusion/ej2-react-barcode-generator';
131
132export default function App() {
133 return (
134 <DataMatrixGeneratorComponent
135 id="datamatrix"
136 value="Syncfusion"
137 width="200px"
138 height="200px"
139 />
140 );
141}
142```
143
144## Common Patterns
145
146### Pattern 1: Dynamic Value Generation
147```tsx
148const [barcodeValue, setBarcodeValue] = React.useState('DEFAULT123');
149
150<BarcodeGeneratorComponent
151 type="Code128"
152 value={barcodeValue}
153 width="200px"
154 height="150px"
155/>
156```
157
158### Pattern 2: Export on Button Click
159```tsx
160const barcodeRef = React.useRef();
161
162const handleExport = () => {
163 barcodeRef.current.exportImage('barcode', 'PNG');
164};
165
166<div>
167 <BarcodeGeneratorComponent
168 ref={barcodeRef}
169 type="Code39"
170 value="SYNC123"
171 width="200px"
172 height="150px"
173 />
174 <button onClick={handleExport}>Download Barcode</button>
175</div>
176```
177
178### Pattern 3: Styled Container
179```tsx
180<div style={{ padding: '20px', border: '1px solid #ddd' }}>
181 <QRCodeGeneratorComponent
182 value="https://example.com"
183 width="250px"
184 height="250px"
185 foreColor="#333"
186 backgroundColor="#fff"
187 />
188</div>
189```
190
191## Key Props
192
193| Prop | Description | Used By |
194|------|-------------|---------|
195| `type` | Barcode type (Code39, Code128, Code11, Code32, Code93, Codabar) | BarcodeGeneratorComponent |
196| `value` | Data to encode | All generators |
197| `width` | Barcode width (string with px) | All generators |
198| `height` | Barcode height (string with px) | All generators |
199| `foreColor` | Dark/bar color | All generators |
200| `backgroundColor` | Light/space color | All generators |
201| `displayText` | Object to customize display text | All generators |
202| `id` | Unique component identifier (required for export) | All generators |
203
204## Common Use Cases
205
2061. **Retail & Inventory**: Code128 barcodes for products and SKUs
2072. **E-commerce**: QR codes linking to product pages or reviews
2083. **Logistics**: Data Matrix for package tracking and labels
2094. **Document Management**: QR codes embedding document metadata
2105. **Marketing**: Dynamic QR codes with analytics
2116. **Healthcare**: Code128/Code39 for specimen/patient labeling
2127. **Form Workflows**: Export barcodes for printing or archival
213
214## Next Steps
215
2161. Choose your generator type based on use case
2172. Read the getting started guide
2183. Review the specific generator documentation
2194. Customize appearance as needed
2205. Implement export if required for your workflow