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