-
Notifications
You must be signed in to change notification settings - Fork 10
QR Code
- QR Code component specification
Team name: TBD
Developer name: Radoslav Karaivanov
Designer name: TBD
TBD
TBD
| # | Author | Date | Description |
|---|---|---|---|
| 1 | Radoslav Karaivanov | 2026-08-05 | Initial draft |
The igc-qr-code component renders a scannable QR (Quick Response) code as an inline SVG,
generated entirely on the client from a string value. It implements the QR code model
(data encoding, error correction, and matrix/module placement) internally, with no
dependency on external QR-generation libraries or network requests.
The component supports optional visual customization - module (dot) and finder-pattern corner shapes, colors via CSS custom properties, and an optional center logo/image that is safely masked out of the code while respecting the chosen error correction level - making it suitable for scenarios such as:
- Payment and ticketing: encoding URLs, IDs, or payment references for scanning with a mobile device
- Marketing collateral: branded QR codes with a logo linking to a website or campaign
- Authentication flows: encoding one-time setup URLs or tokens (e.g., Wi-Fi credentials, TOTP secrets)
- Contact sharing: encoding vCard or contact information for quick import
- Physical/digital bridging: linking printed materials or products to digital content
-
Automatic encoding: Automatically selects the most compact QR encoding mode
(numeric, alphanumeric, or byte) and the smallest QR version that fits the provided
value, unless an explicitversionis supplied -
Configurable error correction: Choose between
L,M,Q, andHerror correction levels, trading data capacity for resilience against damage or obstruction -
Center logo support: Optionally overlay a logo image at the center of the code; the
component automatically masks the underlying modules and, when
error-levelis not explicitly set, escalates to the smallest error correction level that keeps the code scannable at the requested logo size -
Visual customization: Independently style the data modules (dots) and the
finder-pattern corners as
square,circle, orrounded - Themeable colors: Control background, module, and corner colors via CSS custom properties, with shadow parts exposed for the background, dots, and each corner element
- Configurable size and margin: Control the rendered pixel size and the quiet-zone margin (expressed in QR modules) independently
-
Safe by default: Validates logo source URLs, rejecting unsafe schemes (e.g.
javascript:,vbscript:) and non-imagedata:URIs -
Accessible: Renders an SVG
<title>for screen readers, derived fromvalueor an explicitaria-label, and passes accessibility audits out of the box
- The component must render an SVG QR code representation whenever a non-empty
valueis set, and render nothing whenvalueis unset. - The component must automatically choose an encoding mode and QR version capable of
encoding the provided
value, unless a specificversionis set, in which case an error should not be thrown for valid inputs that fit within that version's capacity. - The
error-levelproperty must control the error correction level used to generate the QR matrix, affecting both resilience and the resulting QR code size/density. - The
sizeandmarginproperties must control the rendered pixel dimensions and quiet zone respectively, without affecting the encoded data. - When
logo-srcis set to a valid, loadable image, the component must render the image centered over the code and mask out the modules beneath it, while keeping the code scannable at the resolved error correction level. - The component must reject unsafe
logo-srcvalues (e.g.javascript:,vbscript:, non-imagedata:URIs) and must gracefully recover if a previously failed logo image is replaced with a valid one. - The
dot-styleandsquare-styleproperties must independently control the rendered shape of the data modules and the finder-pattern corners. - Colors must be fully customizable via the documented CSS custom properties, and must not automatically invert based on light/dark theme selection.
- The element must be integrated and themeable with the theming mechanism of the library.
- The element must be WAI-ARIA compliant and pass accessibility audits.
- The component must handle edge cases gracefully (empty/undefined value, broken logo images, degenerate logo sizes, unsafe URLs).
As an end-user, I expect to be able to:
- see a QR code rendered on the page that I can scan with a mobile device's camera or a QR scanning app.
- see a QR code that still scans correctly even when a logo is present at its center.
- have the QR code's purpose be announced by my screen reader (e.g. "QR code:
<value>" or a custom label) if I cannot see the visual code.
As a developer, I expect to be able to:
- set the
valueto be encoded as a QR code, without having to manage any QR-generation logic myself. - control the error correction level to balance data capacity against resilience to damage/obstruction.
- optionally pin a specific QR
versionwhen I need a predictable code size/density. - control the rendered pixel
sizeand the quiet-zonemargin. - add a center logo image via
logo-src, and control how much of the code it may cover vialogo-size, and its surrounding whitespace vialogo-margin. - rely on the component to automatically pick a safe error correction level for the requested logo size when I have not explicitly set one.
- style the data modules and finder-pattern corners independently via
dot-styleandsquare-style. - theme the QR code's colors via CSS custom properties, and target its internal elements via shadow parts for advanced styling.
- provide a custom
aria-labelto control what is announced to assistive technology.
The igc-qr-code component presents users with a static, scannable QR code:
Visual Structure
- A square SVG graphic containing the QR code's finder-pattern corners (three square markers in the top-left, top-right, and bottom-left) and the data modules that encode the value.
- An optional logo image centered within the code, with the underlying modules masked out so the logo does not interfere with scanning.
- A quiet-zone margin surrounding the code, as required for reliable scanning by QR readers.
There is no direct end-user interaction with the component; its content is driven entirely
by properties set by the hosting application. When the encoded value or any visual
property changes, the rendered SVG updates immediately to reflect the new state.
Accessibility Experience
- Screen readers announce the presence and purpose of the QR code via an SVG
<title>element, using either thevalueor a developer-suppliedaria-label.
The igc-qr-code component is designed for ease of integration with a declarative API and
sensible defaults, requiring only a value to render a working QR code.
The simplest QR code requires only a value:
<igc-qr-code value="https://www.infragistics.com"></igc-qr-code>By default, this creates a 128×128px QR code with a 4-module margin, M error correction,
and square modules/corners.
<igc-qr-code
value="https://www.infragistics.com"
size="256"
margin="2"
error-level="H"
></igc-qr-code><!-- Forces a fixed-size QR code regardless of value length, as long as it fits -->
<igc-qr-code value="12345" version="4"></igc-qr-code><igc-qr-code
value="https://www.infragistics.com"
logo-src="/assets/logo.png"
logo-size="0.5"
logo-margin="4"
></igc-qr-code>When error-level is not explicitly set, the component automatically escalates to the
smallest error correction level that keeps the code scannable at the requested logo-size.
<igc-qr-code
value="https://www.infragistics.com"
dot-style="rounded"
square-style="circle"
></igc-qr-code><igc-qr-code
value="https://www.infragistics.com"
style="
--ig-qr-code-background: #e8f4ff;
--ig-qr-code-dark-color: #0066cc;
--ig-qr-code-corner-square-color: #003366;
"
></igc-qr-code>const qrCode = document.querySelector('igc-qr-code');
// Update the encoded value at runtime
qrCode.value = 'https://www.infragistics.com/products';
// Adjust visual properties
qrCode.dotStyle = 'rounded';
qrCode.size = 320;
// Provide a custom accessible label
qrCode.ariaLabel = 'Scan to visit our product page';The QR code component does not contain any visible text content that requires
localization. Developers can provide a localized aria-label attribute to control the
accessible name announced to assistive technology.
Not applicable. The igc-qr-code component is a non-interactive, presentational element
and does not participate in the tab order or respond to keyboard input.
| Name | Attribute | Type | Default value | Description |
|---|---|---|---|---|
| value | value | string | undefined | The value to be encoded in the QR code. |
| version | version | number | undefined | The QR version (1-40) to generate. When not set, the smallest version that fits value is chosen automatically. |
| errorLevel | error-level | 'L' | 'M' | 'Q' | 'H' | 'M' | The error correction level used when generating the QR code. |
| size | size | number | 128 | The rendered width/height of the QR code, in pixels. |
| margin | margin | number | 4 | The quiet-zone margin around the QR code, expressed in QR modules. |
| logoSrc | logo-src | string | undefined | The source URL of an optional logo image rendered at the center of the QR code. |
| logoSize | logo-size | number | 0.4 | The size of the logo, as a ratio (0-1) of the maximum area that can safely be obscured while remaining scannable. |
| logoMargin | logo-margin | number | undefined | The margin around the logo, in pixels. |
| dotStyle | dot-style | 'square' | 'circle' | 'rounded' | 'square' | The shape of the data modules (dots) and the inner finder-pattern corner dot. |
| squareStyle | square-style | 'square' | 'circle' | 'rounded' | 'square' | The shape of the outer finder-pattern corner squares. |
None.
None. The component is a static, presentational element and does not dispatch custom events.
None. The component does not accept slotted content; the QR code is rendered entirely as an internal SVG based on the configured properties.
| Name | Description | Default |
|---|---|---|
--ig-qr-code-background |
The background color of the QR code. | white |
--ig-qr-code-dark-color |
The color of the data modules, and the corner square/dot colors unless overridden. | black |
--ig-qr-code-corner-square-color |
The color of the outer finder-pattern corner squares. Defaults to --ig-qr-code-dark-color. |
- |
--ig-qr-code-corner-dot-color |
The color of the inner finder-pattern corner dots. Defaults to --ig-qr-code-dark-color. |
- |
| Name | Description |
|---|---|
| background | The background rect of the QR code. |
| dots | The data modules (dots) of the QR code. |
| corner-square | The outer corner (finder-pattern) squares of the QR code. |
| corner-dot | The inner corner (finder-pattern) dots of the QR code. |
- Default rendering
- Component renders nothing when
valueis not set - Component renders an SVG element once
valueis set - SVG
width/heightattributes match thesizeproperty - SVG contains a background
rectand at least one datapath - SVG contains three finder-pattern corner groups
- Component renders nothing when
- Value changes
- Setting
valuerenders the corresponding QR code - Changing
valuere-renders the SVG content - Clearing
value(setting toundefined) removes the SVG
- Setting
- Default property values
-
sizedefaults to128 -
margindefaults to4 -
errorLeveldefaults to'M' -
dotStyledefaults to'square' -
squareStyledefaults to'square' -
valuedefaults toundefined
-
- Automatic version/encoding selection
- The component selects the smallest QR version able to encode the given
valuewhenversionis not set - Setting
versionexplicitly forces that QR version, provided the value fits
- The component selects the smallest QR version able to encode the given
- Error correction level
- A higher
errorLevelproduces a larger/denser QR code for the samevalue - Attribute
error-levelcorrectly reflects into theerrorLevelproperty - Attribute
versioncorrectly reflects into theversionproperty (as a number)
- A higher
- Size and margin
- Setting
sizeupdates the SVGwidth/heightattributes - Changing
sizedynamically updates SVG dimensions - Setting
marginadjusts the quiet-zone area without altering encoded data
- Setting
- Dot and corner styles
-
dot-styleofsquare,circle, androundedeach render a valid data path -
square-styleofsquare,circle, androundedeach render three corner groups - Attribute variants correctly reflect into
dotStyle/squareStyleproperties
-
- Shadow parts and CSS custom properties
-
background,dots,corner-square, andcorner-dotparts are exposed and queryable - Default colors match the schema (white background, black modules/corners)
-
--ig-qr-code-backgroundand--ig-qr-code-dark-coloroverride the rendered colors -
--ig-qr-code-dark-colorcascades tocorner-square/corner-dotcolors when those are not explicitly set - An explicit
--ig-qr-code-corner-dot-colorwins over thedark-colorcascade for the corner dot only - Colors do not automatically invert when the global theme switches to a dark variant
-
- Logo rendering
- No
<image>/<mask>/<defs>are rendered whenlogoSrcis not set - A valid
logoSrcrenders an<image>and a<mask>, applied to the group containing dots and finder patterns - The
<image>element is rendered outside the masked group - The mask
idremains stable across re-renders triggered by unrelated property changes - Clearing
logoSrcremoves the<image>/<mask>/<defs>
- No
- Logo URL validation
- Unsafe schemes (
javascript:,vbscript:, case-insensitive) are rejected; no image is rendered - Non-image
data:URIs (e.g.data:text/html,...,data:application/javascript,...) are rejected -
data:image/...URIs are accepted - Regular
https://URLs are accepted - Replacing a valid
logoSrcwith an unsafe one removes the previously rendered<image>/<mask>
- Unsafe schemes (
- Logo load errors
- A broken/undecodable image results in no
<image>/<mask>being rendered - The component recovers and renders the logo once
logoSrcis changed to a valid image
- A broken/undecodable image results in no
- Logo sizing and margin
-
logoSizecontrols the rendered logo's area relative to the safe area for the resolved error correction level - A higher
errorLevelallows for a larger rendered logo at the samelogoSize -
logoMarginreduces the visible logo dimensions relative to the cleared mask area - No
<image>is rendered when the resolved logo box collapses to zero (e.g.logo-size="0")
-
- Automatic error correction escalation
- When
errorLevelis not explicitly set and a logo is present, the component automatically selects the smallest error correction level that accommodates the requestedlogoSize
- When
- Property/attribute synchronization
-
dot-style,square-style,error-level,version,logo-src,logo-size, andlogo-marginattributes correctly initialize their corresponding properties
-
- ARIA and screen reader support
- The component passes the accessibility audit when a
valueis set - The rendered SVG has
role="img" - The SVG contains a
<title>element for screen readers - The
<title>content defaults toQR code: <value>when noaria-labelis set - The
<title>content uses thearia-labelvalue when one is provided
- The component passes the accessibility audit when a
- Invalid/degenerate configurations
- An empty or
undefinedvalue renders no SVG - Extremely small
logoSize/logoMargincombinations that collapse the logo box are handled gracefully (no image rendered, no errors thrown) - Rapid successive property changes (
value,size,logoSrc) do not leave the SVG in an inconsistent state
- An empty or
- The rendered
<svg>element must haverole="img". - The rendered
<svg>must contain a<title>element describing the QR code's purpose, derived fromariaLabelwhen set, or defaulting toQR code: <value>.
Not applicable. The component renders a non-interactive, static graphic and does not receive focus.
The QR code's visual structure (finder patterns and data modules) is a fixed, standardized layout defined by the QR specification and must not be mirrored in Right-to-Left contexts. No additional RTL-specific configuration is required or supported.