How to Implement Custom QR Code Colors
QR codes have evolved from simple black-and-white patterns into powerful branding tools. In 2025, businesses recognize that a well-designed QR code can reinforce brand identity while maintaining full scannability. Customizing the foreground and background colors of your QR codes allows you to create visually appealing designs that stand out.
IronQR makes it simple to modify QR code colors using the QrStyleOptions class. You can change the foreground color (the dark modules), the background color, or both to match your brand guidelines.
In this how-to guide, we'll walk through different ways to customize QR code colors using IronQR in C#.
Quickstart: Customize QR Code Colors
Set foreground and background colors through QrStyleOptions and save the styled QR code.
-
Install IronQR with NuGet Package Manager
PM > Install-Package IronQR -
Copy and run this code snippet.
var qrCode = QrWriter.Write("https://example.com"); var style = new QrStyleOptions { Color = Color.DarkBlue, BackgroundColor = Color.LightYellow }; qrCode.Save(style).SaveAs("colored-qr.png"); -
Deploy to test on your live environment
Start using IronQR in your project today with a free trial
Minimal Workflow (5 steps)
- Download the C# library to create QR codes with custom colors
- Create a QR code using the
QrWriterclass - Initialize
QrStyleOptionsto configure appearance - Set the
ColorandBackgroundColorproperties - Save the styled QR code using
SaveAs
Change Background Color
The background color of a QR code is the lighter area surrounding the dark modules. By default, this is white, but you can change it to any color that provides sufficient contrast with the foreground.
Setting a custom background color is useful when placing QR codes on colored surfaces or when you want to match your brand's color palette. Just ensure there's enough contrast for scanners to read the code reliably.
:path=/static-assets/qr/content-code-examples/how-to/implement-custom-qr-code-background.cs
using IronQr;
using IronSoftware.Drawing;
// Create a QR code
QrCode qr = QrWriter.Write("https://ironsoftware.com/csharp/qr/");
// Set background color
QrStyleOptions styleOptions = new QrStyleOptions()
{
BackgroundColor = Color.LightBlue
};
// Save QR code with custom background
AnyBitmap qrImage = qr.Save(styleOptions);
qrImage.SaveAs("qrBackgroundColor.png");
Imports IronQr
Imports IronSoftware.Drawing
' Create a QR code
Dim qr As QrCode = QrWriter.Write("https://ironsoftware.com/csharp/qr/")
' Set background color
Dim styleOptions As New QrStyleOptions() With {
.BackgroundColor = Color.LightBlue
}
' Save QR code with custom background
Dim qrImage As AnyBitmap = qr.Save(styleOptions)
qrImage.SaveAs("qrBackgroundColor.png")
Change Foreground Color
The foreground color represents the dark modules of the QR code—the actual data pattern that scanners read. While black is the standard choice, you can use any darker color that maintains good contrast against your background.
Changing the foreground color lets you incorporate your brand's primary color into the QR code design. Deep blues, dark greens, or rich burgundies work well as alternatives to black.
:path=/static-assets/qr/content-code-examples/how-to/implement-custom-qr-code-foreground.cs
using IronQr;
using IronSoftware.Drawing;
// Create a QR code
QrCode qr = QrWriter.Write("https://ironsoftware.com/csharp/qr/");
// Set background color
QrStyleOptions styleOptions = new QrStyleOptions()
{
Color = Color.PaleVioletRed
};
// Save QR code with custom background
AnyBitmap qrImage = qr.Save(styleOptions);
qrImage.SaveAs("qrBackgroundColor.png");
Imports IronQr
Imports IronSoftware.Drawing
' Create a QR code
Dim qr As QrCode = QrWriter.Write("https://ironsoftware.com/csharp/qr/")
' Set background color
Dim styleOptions As New QrStyleOptions() With {
.Color = Color.PaleVioletRed
}
' Save QR code with custom background
Dim qrImage As AnyBitmap = qr.Save(styleOptions)
qrImage.SaveAs("qrBackgroundColor.png")
Conclusion
Customizing QR code colors with IronQR opens up creative possibilities while keeping your codes fully functional:
- Background Color: Use
BackgroundColorto change the lighter area behind the QR pattern - Foreground Color: Use
Colorto modify the dark modules that encode your data - Combined Styling: Set both properties together for complete brand alignment
Remember to maintain adequate contrast between foreground and background colors to ensure reliable scanning across different devices and lighting conditions.
For more styling options including logos, margins, and dimensions, visit the IronQR documentation or explore additional code examples on GitHub.
Frequently Asked Questions
How can I customize the colors of a QR code using IronQR?
You can customize the colors of a QR code using IronQR by utilizing the `QrStyleOptions` class. This allows you to set the foreground color with the `Color` property and the background color with the `BackgroundColor` property, providing a way to match your brand's visual identity.
What is the importance of maintaining contrast in QR code colors?
Maintaining contrast between the foreground and background colors of a QR code is crucial to ensure that scanners can reliably read the code. IronQR allows you to change these colors while ensuring that the necessary contrast is maintained for functionality.
Can I use IronQR to match QR code colors to my brand?
Yes, IronQR enables you to adjust both the foreground and background colors of a QR code to align with your brand's color palette, enhancing brand identity while ensuring the QR code remains scannable.
How do I set a custom background color for a QR code in IronQR?
To set a custom background color for a QR code using IronQR, use the `BackgroundColor` property within the `QrStyleOptions` class, enabling you to match the QR code with colored surfaces or brand colors.
What steps are involved in creating a QR code with custom colors using IronQR?
The steps include downloading the IronQR library, creating a QR code with the `QrWriter` class, initializing `QrStyleOptions` to set the `Color` and `BackgroundColor`, and saving the styled QR code using the `SaveAs` method.
Is it possible to change the foreground color of a QR code with IronQR?
Yes, you can change the foreground color of a QR code with IronQR by setting the `Color` property in the `QrStyleOptions` class, allowing the incorporation of your brand's primary colors into the QR code design.
What are the advantages of using custom QR code colors?
Custom QR code colors can enhance brand identity and aesthetic appeal, making QR codes more engaging and recognizable while maintaining their core functionality and scannability, a feature supported by IronQR.
Where can I find more examples of QR code styling using IronQR?
More examples of QR code styling with IronQR can be found in the [IronQR documentation](https://ironsoftware.com/csharp/qr/) and additional code examples are available on [GitHub](https://github.com/iron-software/IronQR.Examples).
Can both foreground and background colors be changed simultaneously in IronQR?
Yes, IronQR allows you to simultaneously change both foreground and background colors by setting the respective properties in the `QrStyleOptions` class, enabling complete customization of QR code appearance.
What is the `QrStyleOptions` class used for in IronQR?
The `QrStyleOptions` class in IronQR is used to customize the appearance of QR codes, including setting the foreground (`Color`) and background (`BackgroundColor`) colors to align with specific design or branding requirements.

