# QR Code [component-header:sl-qr-code] Generates a [QR code](https://www.qrcode.com/) and renders it using the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API). QR codes are useful for providing small pieces of information to users who can quickly scan them with a smartphone. Most smartphones have built-in QR code scanners, so simply pointing the camera at a QR code will decode it and allow the user to visit a website, dial a phone number, read a message, etc. ```html preview

``` ```jsx react import { useState } from 'react'; import { SlQrCode, SlInput } from '@shoelace-style/shoelace/dist/react'; const css = ` .qr-overview { max-width: 256px; } .qr-overview sl-input { margin-top: 1rem; } `; const App = () => { const [value, setValue] = useState('https://shoelace.style/'); return ( <>

setValue(event.target.value)} />
); }; ``` ## Examples ### Colors Use the `fill` and `background` attributes to modify the QR code's colors. You should always ensure good contrast for optimal compatibility with QR code scanners. ```html preview ``` ```jsx react import { SlQrCode } from '@shoelace-style/shoelace/dist/react'; const App = () => ; ``` ### Size Use the `size` attribute to change the size of the QR code. ```html preview ``` ```jsx react import { SlQrCode } from '@shoelace-style/shoelace/dist/react'; const App = () => ; ``` ### Radius Create a rounded effect with the `radius` attribute. ```html preview ``` ```jsx react import { SlQrCode } from '@shoelace-style/shoelace/dist/react'; const App = () => ; ``` ### Error Correction QR codes can be rendered with various levels of [error correction](https://www.qrcode.com/en/about/error_correction.html) that can be set using the `error-correction` attribute. This example generates four codes with the same value using different error correction levels. ```html preview
``` ```jsx react import { SlQrCode } from '@shoelace-style/shoelace/dist/react'; const css = ` .qr-error-correction { display: flex; flex-wrap: wrap; gap: 1rem; } `; const App = () => { return ( <>
); }; ``` [component-metadata:sl-qr-code]