---
title: "SVG output & styling — QR for Laravel | Roundly"
description: "One deterministic, accessible SVG path — module and finder styles, colours, responsive sizing and the Svg value object."
url: https://roundly-consulting.com/open-source/docs/qr-for-laravel/svg-rendering
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[QR for Laravel](https://roundly-consulting.com/open-source/docs/qr-for-laravel.md)

# SVG output & styling

Output is SVG only: one even-odd <path> in module units (a second one when the finder colour differs) with an exact viewBox, an accessible title and description, and no IDs or timestamps — so it is deterministic, yields a stable ETag, and duplicates safely on one page:

```
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29 29" width="256" height="256" role="img" aria-label="QR code" shape-rendering="crispEdges"><title>QR code</title><desc>…</desc><rect width="29" height="29" fill="#ffffff"/><path fill="#000000" fill-rule="evenodd" d="M4 4h7v7h-7z…"/></svg>
```

## Styles

```php
use RoundlyConsulting\Qr\Enums\{FinderStyle, ModuleStyle};

// Rounded modules read less reliably — pair them with Q or H
Qr::url($link)->moduleStyle(ModuleStyle::Rounded, 0.35)->errorCorrection('Q')->svg();

// Dots with rounded, coloured finders
Qr::url($link)
    ->moduleStyle(ModuleStyle::Dots)
    ->finderStyle(FinderStyle::Rounded, '#0a58ca')
    ->errorCorrection('H')
    ->svg();

// Responsive, inherits the text colour, no background rectangle
Qr::url($link)->size(null)->foreground('currentColor')->background('transparent')->svg();
```

- ModuleStyle::Square — traced outlines with crisp edges (the default).
- ModuleStyle::Rounded — convex corners become quarter arcs of the given radius (0 < r ≤ 0.5 modules).
- ModuleStyle::Dots — one circle per dark module.
- FinderStyle::Square — square finder rings and centres (the default), even with rounded or dot modules and in any finder colour.
- FinderStyle::Rounded — rounded finder rings and centres, optionally in their own colour.
- Colours — hex, rgb()/rgba(), CSS named colours, currentColor; transparent omits the background rectangle.
- size(null) — a responsive SVG with viewBox only, sized by your CSS.

## Styling guidance

Keep strong contrast (dark on light), a quiet zone of 4 modules and an opaque background. Rounded modules, dots and coloured finders read less reliably; use error correction Q or H with them. Payment codes should stay square and black on white.

## The Svg value object

```php
use RoundlyConsulting\Qr\Enums\DataUriEncoding;

$svg = Qr::url($link)->svg();

$svg->toString();                                  // the markup
$svg->withXmlDeclaration()->toString();            // prefixed with <?xml …?>
$svg->withAttributes(['class' => 'qr', 'aria-hidden' => 'true']);
$svg->toImgTag('Scan me', ['class' => 'w-32']);    // HtmlString: <img src="data:…">
$svg->toDataUri();                                 // percent-encoded data URI
$svg->toDataUri(DataUriEncoding::Base64);          // base64 data URI
$svg->etag();                                      // quoted SHA-256 prefix
$svg->width();                                     // ?int — null when responsive
$svg->viewBoxSize();                               // modules, quiet zone included
$svg->matrix();                                    // QrMatrix
$svg->sensitivity();                               // Sensitivity
```

Extra attributes are allow-listed (class, style, id, data-\*, aria-\*) and escaped; an existing key such as aria-label is replaced. Text and colours pass through escaping and an allow-list, so page content can’t inject scripts into the image.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/qr-for-laravel.md)
