Skip to content

Adding a Label

A caption underneath the code tells a payer what they're scanning. On a printed card, it's often the difference between a code people use and a code people ignore.

php
RaastQr::make()
    ->amount($order->total)
    ->label('Order #1042')
    ->toPng();

Sizing and Fonts

php
RaastQr::make()->label('Scan to pay', size: 20)->toPng();

By default the renderer's bundled font is used. Point at your own .ttf if you need brand type:

php
RaastQr::make()->label(
    'Scan to pay',
    size: 22,
    font: resource_path('fonts/Inter-SemiBold.ttf')
)->toPng();

Labels are a PNG feature

Labels are drawn as raster text. They work in PNG output; for SVG, put the caption in your own markup around the code instead, which gives you far better typographic control anyway.

Setting a Default

php
// config/raast-qr.php
'label' => [
    'text' => 'Scan to pay',
    'size' => 16,
    'font' => null,
],

What to Put in It

Good labels are specific:

php
->label('Order #' . $order->id)
->label('Invoice ' . $invoice->number . ' — PKR ' . number_format($invoice->total))
->label($business->name)

Less useful:

php
->label('QR Code')          // they can see that
->label($iban)              // long, and the app shows it anyway

Prefer Markup Where You Can

On a web page, you almost always get a better result putting the caption in HTML rather than baking it into the image:

blade
<figure class="text-center">
    <x-raast-qr :amount="$order->total" size="320" />
    <figcaption class="mt-3 text-sm text-gray-600">
        Order #{{ $order->id }} — PKR {{ number_format($order->total) }}
    </figcaption>
</figure>

That stays selectable, translatable and screen-reader friendly. Save the baked-in label for images that will travel on their own — a WhatsApp attachment, or a print job.


Made with ❤️ from Pakistan