English | ç®€ä½“ä¸æ–‡
QRCodeCanvasandQRCodeSVGexports for different rendering targets.- Supports custom size, colors, title text, margins, error correction level, and minimum QR version.
- Supports embedded logo images with excavation and optional cross-origin handling.
- TypeScript definitions for QR props and image settings.
npm install @rc-component/qrcodeimport { QRCodeCanvas } from '@rc-component/qrcode';
export default () => (
<QRCodeCanvas value="https://ant.design" size={200} title="Ant Design" />
);import { QRCodeSVG } from '@rc-component/qrcode';
export default () => (
<QRCodeSVG
value="https://ant.design"
size={200}
level="H"
imageSettings={{
src: 'https://avatars0.githubusercontent.com/u/9441414?s=30&v=4',
width: 30,
height: 30,
excavate: true,
}}
/>
);Run the local dumi site:
npm install
npm startThen open http://localhost:8000.
QRCodeCanvas accepts QRProps plus native canvas attributes.
QRCodeSVG accepts QRProps plus native SVG attributes.
| Name | Type | Default | Description |
|---|---|---|---|
bgColor |
string | '#FFFFFF' |
Background color. |
boostLevel |
boolean | true | Allow the encoder to raise the error correction level when possible without increasing QR version. |
fgColor |
string | '#000000' |
Foreground color. |
imageSettings |
ImageSettings | - | Embedded image configuration. |
includeMargin |
boolean | false | Deprecated. Use marginSize instead. |
level |
'L' | 'M' | 'Q' | 'H' |
'L' |
Error correction level. |
marginSize |
number | 0 | Margin size in QR modules. |
minVersion |
number | 1 | Minimum QR Code version from 1 to 40. |
size |
number | 128 | Rendered size in pixels. |
style |
React.CSSProperties | - | Element style. |
title |
string | - | Accessible title. |
value |
string | string[] | - | Content encoded into the QR Code. |
| Name | Type | Default | Description |
|---|---|---|---|
crossOrigin |
'anonymous' | 'use-credentials' | '' |
- | Cross-origin behavior for the embedded image. |
excavate |
boolean | - | Clear QR modules under the embedded image. |
height |
number | - | Image height in pixels. |
opacity |
number | 1 | Image opacity from 0 to 1. |
src |
string | - | Image URI. |
width |
number | - | Image width in pixels. |
x |
number | centered | Horizontal offset. |
y |
number | centered | Vertical offset. |
npm install
npm start
npm test
npm run tsc
npm run compile
npm run buildThe dumi site runs at http://localhost:8000 by default.
npm run prepublishOnlyThe release flow is handled by @rc-component/np through the rc-np command after the package build.
@rc-component/qrcode is released under the MIT license.