Kaizen
Browse modulesQR codeqr-code/sharedFunctions

Function: renderQrCodeSvg()

function renderQrCodeSvg(value: string, options: {
  backgroundColor?: string;
  description?: string;
  errorCorrectionLevel?: "L" | "M" | "Q" | "H";
  minContrastRatio?: number;
  moduleColor?: string;
  quietZone?: number;
  size?: number;
  title: string;
}): string;

Defined in: shared/qr-code/svg.ts:185

Encode value and render it as a standalone SVG document string.

Isomorphic — no canvas, no DOM. Use it server-side to embed a QR code in a generated PDF/DOCX or a printed receipt, or client-side wherever an SVG string is more convenient than the QRCode UDS component.

Parameters

ParameterTypeDescription
valuestring-
options{ backgroundColor?: string; description?: string; errorCorrectionLevel?: "L" | "M" | "Q" | "H"; minContrastRatio?: number; moduleColor?: string; quietZone?: number; size?: number; title: string; }-
options.backgroundColor?stringPaint for the light modules and quiet zone. Same constraints as moduleColor.
options.description?stringLonger text alternative, rendered as <desc>.
options.errorCorrectionLevel?"L" | "M" | "Q" | "H"See qrCodeErrorCorrectionLevelSchema.
options.minContrastRatio?numberContrast floor enforced between moduleColor and backgroundColor. Can only be raised, not lowered — QR_CODE_MIN_CONTRAST_RATIO is both the default and the floor, since a symbol below it is unreliable to scan regardless of what the caller would prefer.
options.moduleColor?stringPaint for the dark modules. Must be a statically resolvable, fully opaque CSS color — a hex or rgb() literal, black, or white. Design tokens (var(--x)) and currentColor are rejected: their contrast can't be verified, and an unverifiable symbol can't be guaranteed to scan.
options.quietZone?numberLight margin in modules on every side. Fixed at the spec minimum by default; there is no reason to go lower, because a caller whose layout already supplies white space loses nothing by keeping the symbol's own quiet zone.
options.size?numberRendered width and height in CSS pixels. The SVG scales losslessly.
options.titlestringAccessible name for the image, rendered as <title>. Required: a QR code is a meaningful image, so Section 508 / WCAG 1.1.1 needs a text alternative. Describe the purpose ("Appointment check-in code"), not the payload.

Returns

string

Throws

See encodeQrCode and assertQrCodePaint.

On this page