Create a QR code to create an easy way to link to a URL or encode other text. Choose the foreground and background color, the error correction level, and save the image as an SVG.
import QRCode from "https://cdn.jsdelivr.net/npm/qrcode@1.5.4/+esm"
export const take = [
{ label: "Link or message", type: "text" },
{ label: "Margin", type: "number", value: 4, min: 0, max: 10 },
{ label: "Foreground", type: "color", value: "black", inline: true },
{ label: "Background", type: "color", value: "white", inline: true },
{
label: "Error correction",
type: "dropdown",
options: [
{ value: "L", label: "Low" },
{ value: "M", label: "Medium" },
{ value: "Q", label: "Quartile" },
{ value: "H", label: "High" },
],
},
]
export const make = ([text, margin, dark, light, errorCorrectionLevel]) => {
if (!text) return
return QRCode.toString(text, {
margin,
errorCorrectionLevel,
color: { light, dark },
}).then((value) => {
return [{ label: "QR Code", type: "image", format: "svg", value }]
})
}