-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd8d37f
commit d207fd7
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: QR Code | ||
description: Displays a QR code image | ||
slug: qr-code | ||
type: component | ||
--- | ||
|
||
<!--@include: @/include/header.md--> | ||
|
||
<!--@include: @/include/install.md--> | ||
|
||
## Usage | ||
|
||
Add the `QrCode` component to your email template to display a QR code. You can specify the content of the QR code, its size, and the error correction level. Include styles as needed. | ||
|
||
```jsx | ||
import { QrCode } from 'jsx-email'; | ||
|
||
const Email = () => { | ||
return ( | ||
<QrCode | ||
src="https://example.com" | ||
alt="QR Code" | ||
size={300} | ||
correctionLevel="H" | ||
/> | ||
); | ||
}; | ||
``` | ||
|
||
::: tip | ||
The `QrCode` component generates a QR code based on the provided `src` prop. It supports various customization options such as size and error correction level. | ||
::: | ||
|
||
## Component Props | ||
|
||
In addition to expressing all of the [Common Component Props](https://react.dev/reference/react-dom/components/common) for `ComponentProps<'img'>`, `QrCode` accepts the following custom props: | ||
|
||
### Props | ||
|
||
```ts | ||
correctionLevel: 'L' | 'M' | 'H'; | ||
``` | ||
|
||
The error correction level for the QR code. Higher levels offer more resilience at the cost of reduced storage capacity. The available levels are 'L' (low), 'M' (medium), and 'H' (high). | ||
|
||
```ts | ||
size: number; | ||
``` | ||
|
||
The size of the QR code in pixels. This size will apply to both width and height unless overridden by specific `width` or `height` props. | ||
|
||
```ts | ||
width?: number; | ||
``` | ||
|
||
(Optional) The width of the wrapping image in pixels. If not provided, the `size` value will be used. | ||
|
||
```ts | ||
height?: number; | ||
``` | ||
|
||
(Optional) The height of the wrapping image in pixels. If not provided, the `size` value will be used. | ||
|
||
```ts | ||
style?: React.CSSProperties; | ||
``` | ||
|
||
(Optional) Custom CSS styles to be applied to the QR code image. | ||
|
||
::: note | ||
Ensure that the `src` prop contains the data or URL you want to encode in the QR code. The QR code will be generated dynamically based on this content. | ||
::: |