2022-12-05 14:15:26 +08:00
---
category: Components
title: QRCode
2024-03-22 14:22:42 +08:00
description: Components that can convert text into QR codes, and support custom color and logo.
2022-12-05 14:15:26 +08:00
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*cJopQrf0ncwAAAAAAAAAAAAADrJ8AQ/original
2023-02-09 22:17:31 +08:00
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*M4PBTZ_n9OgAAAAAAAAAAAAADrJ8AQ/original
2022-12-05 14:15:26 +08:00
demo:
cols: 2
group:
title: Data Display
order: 5
2024-04-02 14:05:03 +08:00
tag: 5.1.0
2022-12-05 14:15:26 +08:00
---
## When To Use
2023-03-05 20:55:16 +08:00
Used when the text needs to be converted into a QR Code.
2022-12-05 14:15:26 +08:00
## Examples
<!-- prettier - ignore -->
< code src = "./demo/base.tsx" > base< / code >
< code src = "./demo/icon.tsx" > With Icon< / code >
2022-12-22 10:29:55 +08:00
< code src = "./demo/status.tsx" > other status< / code >
2024-07-12 10:49:47 +08:00
< code src = "./demo/customStatusRender.tsx" version = "5.20.0" > custom status render< / code >
2023-05-25 13:32:48 +08:00
< code src = "./demo/type.tsx" > Custom Render Type< / code >
2022-12-05 14:15:26 +08:00
< 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 >
## API
2023-08-08 18:27:48 +08:00
Common props ref: [Common props](/docs/react/common-props)
2022-12-05 14:15:26 +08:00
> This component is available since `antd@5.1.0`
2023-05-09 17:24:28 +08:00
| Property | Description | Type | Default | Version |
| :-- | :-- | :-- | :-- | :-- |
2023-03-05 20:55:16 +08:00
| value | scanned text | string | - |
2023-05-25 13:32:48 +08:00
| type | render type | `canvas \| svg ` | `canvas` | 5.6.0 |
2022-12-05 14:15:26 +08:00
| icon | include image url (only image link are supported) | string | - |
2023-11-13 18:35:23 +08:00
| size | QRCode size | number | 160 |
2024-06-10 17:47:45 +08:00
| iconSize | include image size | number \| { width: number; height: number } | 40 | 5.19.0 |
2022-12-05 14:15:26 +08:00
| color | QRCode Color | string | `#000` |
2023-05-09 17:24:28 +08:00
| bgColor | QRCode Background Color | string | `transparent` | 5.5.0 |
2022-12-05 14:15:26 +08:00
| bordered | Whether has border style | boolean | `true` |
| errorLevel | Error Code Level | `'L' \| 'M' \| 'Q' \| 'H' ` | `M` |
2023-12-30 14:52:08 +08:00
| status | QRCode status | `active \| expired \| loading \| scanned` | `active` | scanned: 5.13.0 |
2024-07-12 10:49:47 +08:00
| statusRender | custom status render | `(info: \[StatusRenderInfo](/components/qr-code-cn#statusrenderinfo)) => React.ReactNode` | 5.20.0 |
2022-12-05 14:15:26 +08:00
| onRefresh | callback | `() => void` | - |
2024-07-12 10:49:47 +08:00
### StatusRenderInfo
```typescript
type StatusRenderInfo = {
status: QRStatus;
locale: Locale['QRCode'];
onRefresh?: () => void;
};
```
2023-04-11 10:25:24 +08:00
## Design Token
< ComponentTokenTable component = "QRCode" > < / ComponentTokenTable >
2022-12-05 14:15:26 +08:00
## FAQ
### About QRCode ErrorLevel
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](https://www.qrcode.com/en/about/error_correction.html)
2024-04-07 17:02:59 +08:00
### ⚠️⚠️⚠️ Cannot scan the QR code?
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.