React library
Add a logo in code
Put a logo in the center of a QR code with the logo and logoOptions props, size and place it, crop it, give it a plate, and keep the code scannable.
QRCode takes a logo prop and lays the image out for you: it clears the modules behind the logo and never draws one bigger than the code can repair. This page covers the layout options, the limits and the raw imageSettings API underneath.
Designing in the playground or the dashboard instead? See Add a logo in Help.
A logo in three lines
import { QRCode } from "qrdx";
export function LogoCode() {
return (
<QRCode value="https://example.com" size={256} level="H" logo="/logo.png" />
);
}logo takes a path in your app, a URL or a data URL. The logo is drawn at a quarter of the code's width, the modules behind it are cleared, and the code relies on error correction to scan. Use level="H" (30% of the code may be damaged) or at least the default Q (25%).

Size, clear space and position
logoOptions lays the logo out in units that do not depend on the render size:
import { QRCode } from "qrdx";
export function PlacedLogoCode() {
return (
<QRCode
value="https://example.com"
size={256}
level="H"
logo="/logo.png"
logoOptions={{ size: 0.2, padding: 1, x: 0.6, y: 0.55 }}
/>
);
}Keep a moved logo off the three corner eyes and off the small square near the bottom right corner (the alignment pattern decoders use to correct perspective). The scan score fails a logo that covers one of them.
How big a logo can be
A logo (with its clear space) spoils every codeword it touches, and each error-correction block repairs only so many. QRCode and getQRData count the spoiled codewords block by block and shrink the logo until the worst block uses at most 60% of its repair capacity (LOGO_EC_SAFETY). Small codes hold less: at level Q a short link fits a logo of about 13% to 17% of the width, and level H or a shorter value makes room for more.
getLogoSizeLimit(props)returns the largestsizethat fits a code, so a slider can stop there.- Raw
imageSettingsonQRCodeSVG,QRCodeCanvasandgetQRAsSVGget the same cap: a logo that fits is drawn as given, a bigger one is shrunk around its own center. autoLevelraises error correction toHwhenever the cleared area covers more than 7% of the code (AUTO_LEVEL_LOGO_COVERAGE). It is off by default, so existing codes keep their level.- The scan score counts the same codewords and warns before the cap would shrink your logo.
The same arithmetic predicts where real decoders stop. In our scan study, jsQR, ZXing-C++ and zbar all read 80% or more of captures with a centred logo right up to the largest one that kept every block within its repair budget, and not past it: 39% of the code's width at level H, 24% at M and 17% at L. The library's 60% cap leaves the rest of each block's budget for scratches, folds and glare.
Shape, plate and background
import { QRCode } from "qrdx";
export function RoundLogoCode() {
return (
<QRCode
value="https://example.com"
size={256}
level="H"
logo="/logo.png"
logoOptions={{ size: 0.22, shape: "circle", plate: "#ffffff" }}
/>
);
}The crop is an SVG clip path. The print PDF and EPS clip to the same outline, so every download looks the same. EPS has no transparency, so the transparent parts of a logo print white there.
If a logo sits on a solid box (common with JPEGs), remove it: removeLogoBackground(src) returns the cleaned PNG as a data URL in the browser, and removeLogoBackdrop(pixels) does the same on RGBA pixels anywhere. When the four corners share one color, they clear that color from the edges inward, so the same color inside the mark (white letters, say) stays. Both return null when the image has no solid background.
Raw image settings
QRCodeSVG and QRCodeCanvas take the logo as imageSettings, in the same pixels as size. Use it when you lay the logo out yourself or port code from another renderer.
import { QRCodeSVG } from "qrdx";
export function ImageSettingsCode() {
return (
<QRCodeSVG
value="https://example.com"
size={512}
level="H"
autoLevel
imageSettings={{
src: "/logo.png",
width: 110,
height: 110,
excavate: true,
padding: 8,
}}
/>
);
}widthandheightare in pixels. Leavexandyout to center the logo.excavateclears the modules behind the logo. Keep it on unless the logo is see-through and you want modules to show through it.paddingclears extra modules around the logo, in the same pixels aswidthandheight.shapeandplatework as inlogoOptions.- The logo keeps its pixel size whatever the
margin.
getQRData(props) turns logo and logoOptions into these imageSettings for a 1024 px code, which is how QRCode and the download helpers share one layout.
Downloads and formats
- PNG and JPEG logos embed in every export. SVG and WebP logos are drawn in the browser's exports and left out of a PNG made on a server.
- For downloads, a data URL is safest. A remote image needs CORS headers before the browser may copy it into the file; without them the file has no logo.
- A PNG with transparency gives the cleanest result on a colored code. For a JPEG, add a
platein the background color or remove its box first. - Test a logo code on two or three phones before you print it, or check it with the scan score.
Related
Was this page helpful?
Last updated on
Round the background, add a halo or a shadow
Round the background's corners with a color around them, rim the dots with a light halo, and give the dots a shadow, within the ranges that keep every look scannable.
Frames, scan score and print files
Draw a call-to-action frame with the frame prop, from the official library or your own spec, check it with getScanScore, export PDF, SVG or EPS at exact sizes.
