Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentQr
Managercreate_qr_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Qr, create_qr_manager } from "sveltekit-ui"

  const manager = create_qr_manager({
    data: "https://svelte.dev",
    size: 180,
    margin: 8,
    is_show_copy: true,
    is_show_download: true,
  })
</script>

<Qr {manager} />

API reference

Configure the manager, call its methods, and read its reactive state.

17 entries in configuration

PropertyTypeDefaultDescription
datastring nullThe primary data/content encoded within the QR code.
imagestring or null (URL) nullOptional image URL to place in the center of the QR code.
image_sizenumber 0.5How large the center image is as a fraction of overall QR size (0.5 means 50%).
sizenumber 200Width/height in px for the QR code.
marginnumber 10Margin in px around the QR code.
type_numbernumber 0Integer (0-40) specifying detail level of QR. 0 means auto, higher means more capacity but bigger code.
error_correction_levelstring QAmount of error correction. 'L' ~7%, 'M' ~15%, 'Q' ~25%, 'H' ~30%. Higher can handle more damage but uses bigger code.
colorstring (CSS color) var(--primary-t)Main dots color of the QR code.
corner_colorstring (CSS color) color-mix(in oklab, var(--primary-t), var(--bg) 20%)Special color for the larger 'corner squares' in the QR code.
background_colorstring (CSS color) var(--shadow1-t)Background fill behind the QR code (the 'negative space' inside the bounding square).
border_colorstring (CSS color) var(--shadow7-t)Border color of the QR container.
border_widthnumber 1Width in px of the QR container border.
border_radiusnumber (size + 2 * margin) / 100Border radius (in rem or direct numeric) for the QR container.
extensionstring svgFile type for the download if is_show_download is true.
qualitynumber (0.0 to 1.0) 0.8Used when downloading as raster formats like png or webp to specify image quality.
is_show_copyboolean falseIf true, displays a text input of `data` plus a button to copy it to clipboard.
is_show_downloadboolean falseIf true, shows a dropdown to pick file extension and a button to download the generated QR.