> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linkx.tr/llms.txt
> Use this file to discover all available pages before exploring further.

# QR Code Colors: RGB, CMYK & Gradients

> Set foreground and background colors using RGB, CMYK, or grayscale models. Add gradients and per-eye color overrides for fully branded Laravel QR codes.

The Laravel QR Code package supports three color models — RGB, CMYK, and grayscale — plus gradients and individual per-eye color overrides. Every color method is chainable, so you can combine them freely before calling `generate()`.

## RGB (Default)

RGB is the default color model. Pass red, green, and blue values on a **0–255** scale to `color()` and `backgroundColor()`.

```php theme={null}
use Linkxtr\QrCode\Facades\QrCode;

// Red foreground, white background
QrCode::color(220, 38, 38)
    ->backgroundColor(255, 255, 255)
    ->generate('https://example.com');
```

![RGB red QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/rgb-red.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=7a8e0cbf54312a8d1ae40a9d68cf332e)

Red foreground (220, 38, 38) on white background

### RGB with Alpha

Add a fourth argument to include an **alpha (transparency) channel**. The scale is **0–100**, where `100` is fully opaque and `0` is fully transparent.

```php theme={null}
// Semi-transparent blue foreground with alpha channel (60) on light gray background
QrCode::color(30, 64, 175, 60)
    ->backgroundColor(241, 245, 249)
    ->generate('https://example.com');
```

> [!WARNING]
>
> Alpha values use a **0–100 scale**, not the 0–255 scale you may be used to
> from CSS or image editors. The package converts this to the correct internal
> representation automatically.

![RGBA semi-transparent QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/rgba-semi-transparent.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=647ef9778afb1f6266150abf23484f31)

Semi-transparent blue foreground with alpha channel (60) on light gray background

## CMYK

Switch to CMYK mode by calling `cmyk()` before `color()`. All four channel values use a **0–100** scale (percentage).

```php theme={null}
// Call cmyk() first, then set C / M / Y / K values
QrCode::cmyk()
    ->color(0, 100, 100, 0)      // pure red in CMYK
    ->backgroundColor(0, 0, 0, 0) // white in CMYK
    ->generate('https://example.com');
```

> [!NOTE]
>
> Gradients are only available in RGB mode. Calling `gradient()` while in CMYK
> mode is not supported.

You can switch back to RGB at any point by calling `rgb()`.

```php theme={null}
QrCode::cmyk()
    ->color(100, 50, 0, 10)
    ->rgb() // switch back to RGB for the background
    ->backgroundColor(255, 255, 255)
    ->generate('https://example.com');
```

## Grayscale

Use `gray()` for a one-call shorthand that sets both foreground and (optionally) background to shades of gray. The scale is **0–100**, where `0` is black and `100` is white.

```php theme={null}
// Dark gray foreground, light gray background
QrCode::gray(20, 92)->generate('https://example.com');

// Black foreground, white background (defaults)
QrCode::gray(0)->generate('https://example.com');
```

* **First argument** — foreground shade (0 = black, 100 = white).
* **Second argument** — background shade. Defaults to `100` (white) when omitted.

![Grayscale QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/grayscale.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=6428cc20cb3e3ab3f655a2e5a0d7390e)

Grayscale: dark gray foreground (20) with light gray background (92)

## Gradients

Apply a two-color gradient to the QR code foreground with `gradient()`. Provide start and end colors as RGB arrays or hex strings, then choose a direction.

```php theme={null}
// Vertical gradient: blue → red
QrCode::gradient([0, 0, 255], [255, 0, 0], 'vertical')
    ->generate('https://example.com');

// Horizontal gradient: green → purple
QrCode::gradient([34, 197, 94], [168, 85, 247], 'horizontal')
    ->generate('https://example.com');

// Diagonal gradient
QrCode::gradient([255, 165, 0], [255, 0, 128], 'diagonal')
    ->generate('https://example.com');
```

### Gradient Types

| Value | Direction |
| - | - |
| `vertical` | Top to bottom |
| `horizontal` | Left to right |
| `diagonal` | Top-left to bottom-right |
| `inverse_diagonal` | Top-right to bottom-left |
| `radial` | Radiates outward from the center |

> [!WARNING]
>
> Gradients are only available in **RGB mode**. Using `gradient()` after calling
> `cmyk()` is not supported.

![Vertical gradient QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/gradient-vertical.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=af74c3987bb349283d32e0a85f4a9182)

Vertical gradient (top to bottom)

![Horizontal gradient QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/gradient-horizontal.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=0fc8dea44414dce29ef5f51f54595a57)

Horizontal gradient (left to right)

![Diagonal gradient QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/gradient-diagonal.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=79590874db2a6b151d2013e3754cb7b5)

Diagonal gradient (top-left to bottom-right)

![Inverse diagonal gradient QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/gradient-inverse-diagonal.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=b53497fe8e5ab4da092665208c809165)

Inverse diagonal (top-right to bottom-left)

![Radial gradient QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/gradient-radial.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=5ea2fe3d320ce08567db0b024186f128)

Radial gradient (center outward)

## Per-Eye Color Overrides

Override the color of any individual eye with `eyeColor()`. Each QR code has three positional eyes indexed `0`, `1`, and `2`.

```php theme={null}
// eyeColor(index, innerColor, outerColor)
QrCode::eyeColor(0, [220, 38, 38], [30, 64, 175])  // eye 0: red inner, blue outer
    ->eyeColor(1, [22, 163, 74], [126, 34, 206])    // eye 1: green inner, purple outer
    ->eyeColor(2, [245, 158, 11], [15, 118, 110])   // eye 2: amber inner, teal outer
    ->generate('https://example.com');
```

* **Index** — `0` (top-left), `1` (top-right), `2` (bottom-left).
* **Inner color** — color of the small inner marker square.
* **Outer color** — color of the outer frame. Omit this argument to apply the inner color to both parts.

```php theme={null}
// Same color for both inner and outer parts of eye 0
QrCode::eyeColor(0, [220, 38, 38])->generate('https://example.com');
```

> [!WARNING]
>
> Custom eye colors require the `ext-imagick` PHP extension when generating
> raster formats like PNG. The GD fallback supports the default foreground
> color only — calling `eyeColor()` without Imagick installed throws a
> `MissingExtensionException`. SVG and EPS output are unaffected and work
> without Imagick.

![Per-eye colors QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/eye-colors-three.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=374efd1a2f31bded3d7cc66ed04f877d)

Per-eye custom color overrides for all three corner positional eyes

## Complete Color Example

Chain color options with style and format options to build a fully branded QR code.

```php theme={null}
use Linkxtr\QrCode\Facades\QrCode;

$qr = QrCode::format('png')
    ->size(400)
    ->style('dot')
    ->eye('circle')
    ->gradient([99, 102, 241], [236, 72, 153], 'diagonal')
    ->backgroundColor(255, 255, 255)
    ->eyeColor(0, [99, 102, 241], [30, 27, 75])
    ->eyeColor(1, [99, 102, 241], [30, 27, 75])
    ->eyeColor(2, [99, 102, 241], [30, 27, 75])
    ->generate('https://example.com');
```

![Complete color example QR code](https://mintcdn.com/laravel-qrcode/e1jio7idcPehW76b/images/colors/complete-color-example.svg?fit=max\&auto=format\&n=e1jio7idcPehW76b\&q=85\&s=31ee69d58a06903da54d36247cec468b)

Complete branded QR code with diagonal gradient, circle eyes, and per-eye color accents

> [card] [Styling](https://docs.linkx.tr/customization/styling.md)
>
> Set module shape, eye style, size, margin, and output format.

> [card] [Image Merge](https://docs.linkx.tr/customization/image-merge.md)
>
> Embed a logo or image into the center of your QR code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.