Kaizen
Browse modulesQR codeqr-code/sharedFunctions

Function: renderQrCodeMatrixSvg()

function renderQrCodeMatrixSvg(matrix: QrCodeMatrix, options: {
  backgroundColor?: string;
  description?: string;
  minContrastRatio?: number;
  moduleColor?: string;
  size?: number;
  title: string;
}): string;

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

Render an already-encoded matrix as a standalone SVG document string.

The markup is accessible by construction: role="img" plus a <title> (and optional <desc>) give the graphic a text alternative in every assistive-technology mapping. Note that a QR code must never be the only route to the information — render the underlying value as visible text alongside it too.

Parameters

ParameterTypeDescription
matrixQrCodeMatrix-
options{ backgroundColor?: string; description?: string; minContrastRatio?: number; moduleColor?: string; 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.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.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

On this page