SVG string renderer
When to use
Section titled “When to use”Use QRCodeSVGRenderer for scalable output in web pages, email, print, generated assets, or HTTP
responses. It is the recommended default when the consumer accepts SVG text.
Minimal example
Section titled “Minimal example”import {QRCodeSVGRenderer, qrcode} from '@qrcodesdk/core';
const svg = qrcode('https://qrcodesdk.dev').render(QRCodeSVGRenderer());Learn here more about using the SVG string in the browser.
Return value
Section titled “Return value”The renderer returns a complete SVG string with an explicit width, height, and viewBox. The root
element has role="img". Output with only square shapes uses shape-rendering="crispEdges"; curved
styles omit that hint.
Renderer-specific options
Section titled “Renderer-specific options”QRCodeSVGRendererOptions accepts the shared visual options
plus these SVG-specific fields:
| Option | Type | Default | Effect |
|---|---|---|---|
alt |
string |
undefined |
Fallback accessible name when ariaLabel is omitted |
ariaLabel |
string |
undefined |
Sets aria-label and takes precedence over alt |
title |
string |
undefined |
Adds a child <title> element |
image.source |
QRCodeDataImageURL |
required with image |
Embeds a prepared data:image/... URL |
image.size |
number |
0.4 |
Image box as a fraction of matrix width |
image.padding |
number |
1 |
Clear padding measured in modules |
image.clearBackground |
boolean |
true |
Clears modules behind the image and padding |
Renderer-specific constraints
Section titled “Renderer-specific constraints”image.sourcemust be a non-empty embedded image data URL. The renderer does not read paths or fetch remote URLs.- Image
sizemust be finite, greater than0, and at most1; padding must be finite and non-negative. - The renderer is runtime-neutral under the Core compatibility contract.
Related guides
Section titled “Related guides”- Customize appearance for shared colors, module shapes, quiet zones, labels, and scan safety.
- Add a center image for preparing an SVG center image source.
- Browser Usage for rendering in the browser.
- Download or save for files and browser downloads.
- Serve a QR code for HTTP responses.