generate().
RGB (Default)
RGB is the default color model. Pass red, green, and blue values on a 0–255 scale tocolor() and backgroundColor().
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, where100 is fully opaque and 0 is fully transparent.
Semi-transparent blue foreground with alpha channel (60) on light gray background
CMYK
Switch to CMYK mode by callingcmyk() before color(). All four channel values use a 0–100 scale (percentage).
gradient() while in CMYK
mode is not supported.rgb().
Grayscale
Usegray() 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.
- First argument — foreground shade (0 = black, 100 = white).
- Second argument — background shade. Defaults to
100(white) when omitted.
Grayscale: dark gray foreground (20) with light gray background (92)
Gradients
Apply a two-color gradient to the QR code foreground withgradient(). Provide start and end colors as RGB arrays or hex strings, then choose a direction.
Gradient Types
Vertical gradient (top to bottom)
Horizontal gradient (left to right)
Diagonal gradient (top-left to bottom-right)
Inverse diagonal (top-right to bottom-left)
Radial gradient (center outward)
Per-Eye Color Overrides
Override the color of any individual eye witheyeColor(). Each QR code has three positional eyes indexed 0, 1, and 2.
- 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.
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.Complete branded QR code with diagonal gradient, circle eyes, and per-eye color accents