Qr Showcase

Example

https://www.sveltekit-ui.com

Example2

Example3

Component Documentation

Component Name

Qr

Builder Function Name

create_qr_manager

Description

Generates a stylized QR code with optional image in the center, supporting download and copying features.

Use like example

Config

PropertyTypeDefaultDescription
datastring

The primary data/content encoded within the QR code.

imagestring or null (URL)

Optional image URL to place in the center of the QR code.

image_sizenumber

0.5

How large the center image is as a fraction of overall QR size (0.5 means 50%).

sizenumber

200

Width/height in px for the QR code.

marginnumber

10

Margin in px around the QR code.

type_numbernumber

0

Integer (0-40) specifying detail level of QR. 0 means auto, higher means more capacity but bigger code.

error_correction_levelstring

Q

Amount 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

1

Width in px of the QR container border.

border_radiusnumber

(size + 2 * margin) / 100

Border radius (in rem or direct numeric) for the QR container.

extensionstring

svg

File type for the download if is_show_download is true.

qualitynumber (0.0 to 1.0)

0.8

Used when downloading as raster formats like png or webp to specify image quality.

is_show_copyboolean

false

If true, displays a text input of `data` plus a button to copy it to clipboard.

is_show_downloadboolean

false

If true, shows a dropdown to pick file extension and a button to download the generated QR.

Methods

MethodDescriptionParametersReturns
init

Initializes the manager with config values, sets up the internal managers (text, copy, download).

No Params

on_mount

Called typically on Svelte's onMount. Creates the QR code with QRCodeStyling and appends to the DOM. If there's an error (e.g. data too large for type_number), sets error_message.

No Params

update

Re-generates/updates the QR code with any changed config (color, data, etc.).

No Params

download

Triggers a file download of the QR code with the chosen extension and quality.

No Params

Returned Properties

PropertyTypeDescription
idstring

Unique ID for the QR container.

error_messagestring or null

Displays any generation errors encountered, e.g. if the data is too large for the chosen type_number/error_correction_level.

is_loadedboolean

True once the QR code is fully rendered. If false, shows a loading spinner.

text_managerobject

A text input manager for the main data. If is_show_copy=true, this is displayed.

copy_button_managerobject

Button manager for copying data to clipboard if is_show_copy=true.

download_button_managerobject

Button manager for triggering the QR code download if is_show_download=true.

extention_dropdown_managerobject

Dropdown manager controlling which extension is used when downloading (svg, png, webp).

icon
Sponsored byContibase