Back to Ant Design

QRCode

components/qr-code/index.en-US.md

6.3.73.9 KB
Original Source

When To Use

Used when the text needs to be converted into a QR Code.

Examples

<!-- prettier-ignore -->

<code src="./demo/base.tsx">base</code> <code src="./demo/icon.tsx">With Icon</code> <code src="./demo/status.tsx">other status</code> <code src="./demo/customStatusRender.tsx" version="5.20.0">custom status render</code> <code src="./demo/type.tsx">Custom Render Type</code> <code src="./demo/customSize.tsx">Custom Size</code> <code src="./demo/customColor.tsx">Custom Color</code> <code src="./demo/download.tsx">Download QRCode</code> <code src="./demo/errorlevel.tsx">Error Level</code> <code src="./demo/Popover.tsx">Advanced Usage</code> <code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code>

API

Common props ref:Common props

This component is available since [email protected]

PropertyDescriptionTypeDefaultVersion
valuescanned textstring | string[]-string[]: 5.28.0
typerender typecanvas | svg canvas5.6.0
iconinclude image url (only image link are supported)string-
sizeQRCode sizenumber160
iconSizeinclude image sizenumber | { width: number; height: number }405.19.0
colorQRCode Colorstring#000
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
bgColorQRCode Background Colorstringtransparent5.5.0
marginSizeQuiet zone size (in modules). 0 means no marginnumber06.2.0
borderedWhether has border stylebooleantrue
errorLevelError Code Level'L' | 'M' | 'Q' | 'H' M
boostLevelIf enabled, the Error Correction Level of the result may be higher than the specified Error Correction Levelbooleantrue5.28.0
statusQRCode statusactive | expired | loading | scannedactivescanned: 5.13.0
statusRendercustom status render(info: [StatusRenderInfo](/components/qr-code-cn#statusrenderinfo)) => React.ReactNode-5.20.0
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
typerender typecanvas | svgcanvas5.6.0
valuescanned textstring-

StatusRenderInfo

typescript
type StatusRenderInfo = {
  status: QRStatus;
  locale: Locale['QRCode'];
  onRefresh?: () => void;
};

Semantic DOM

<code src="./demo/_semantic.tsx" simplify="true"></code>

Design Token

<ComponentTokenTable component="QRCode"></ComponentTokenTable>

FAQ

About QRCode ErrorLevel {#faq-error-correction-level}

The ErrorLevel means that the QR code can be scanned normally after being blocked, and the maximum area that can be blocked is the error correction rate.

Generally, the QR code is divided into 4 error correction levels: Level L can correct about 7% errors, Level M can correct about 15% errors, Level Q can correct about 25% errors, and Level H can correct about 30% errors. When the content encoding of the QR code carries less information, in other words, when the value link is short, set different error correction levels, and the generated image will not change.

For more information, see the: https://www.qrcode.com/en/about/error_correction

⚠️⚠️⚠️ Cannot scan the QR code? {#faq-cannot-scan}

If the QR code cannot be scanned for identification, it may be because the link address is too long, which leads to too dense pixels.

You can configure the QR code to be larger through size, or shorten the link through short link services.