QR Code
Generate accessible, themeable QR codes locally as crisp SVG graphics.
c2-qr-code encodes text, URLs, contact details, Wi-Fi credentials, and other payloads entirely in the browser. It renders a scalable SVG, offers four error-correction levels and a reliable quiet zone, and can export the result as SVG or PNG.
Installation
npm install @c2n/qr-codeUsage
Use error-correction="H" when adding center content, and keep that content small. The default four-module margin is the recommended quiet zone; avoid reducing it unless the surrounding layout provides equivalent empty space.
Export the generated artwork from JavaScript:
const code = document.querySelector('c2-qr-code')
const svg = code.toSVG()
const pngDataUrl = await code.toDataURL('png', 4)
await code.download('event-ticket', 'png')