slice icon Context Slice

Styled QR Code Generation

Generate beautiful, branded QR codes with custom styling.

Basic Usage

Run codeGenerate Styled QR Code with:

  1. text — Content to encode (URL, text, etc.)
  2. outputDir — Where to save (use uiGenerated QR Codes Output path)
  3. options — JSON object with styling options

Styling Options

Pass as JSON string in the third argument:

{
  "size": 400,
  "format": "png",
  "dotStyle": "rounded",
  "dotColor": "#1a1a2e",
  "cornerStyle": "extra-rounded",
  "cornerColor": "#e94560",
  "backgroundColor": "#ffffff",
  "gradient": {
    "type": "linear",
    "colors": ["#667eea", "#764ba2"],
    "rotation": 45
  },
  "logoPath": "./assets/logo.png",
  "logoSize": 0.25,
  "errorCorrectionLevel": "H"
}

Dot Styles

Style Description
square Classic blocky QR (default)
dots Circular dots
rounded Rounded square corners
extra-rounded More pronounced rounding
classy Elegant connected style
classy-rounded Classy with rounded edges

Corner Styles

The three position markers can be styled independently:

Option Values Description
cornerStyle square, dot, extra-rounded Outer corner squares
cornerDotStyle square, dot Inner corner dots
cornerColor hex color Outer square color
cornerDotColor hex color Inner dot color

Gradients

Apply gradients to the QR modules:

{
  "gradient": {
    "type": "linear",
    "colors": ["#ff6b6b", "#feca57", "#48dbfb"],
    "rotation": 90
  }
}
  • type: linear or radial
  • colors: Array of hex colors (2 or more)
  • rotation: Angle in degrees (linear only)

Logo Embedding

Add a centered logo while maintaining scannability:

{
  "logoPath": "./path/to/logo.png",
  "logoSize": 0.3,
  "errorCorrectionLevel": "H"
}
  • logoPath: Path to PNG/JPG image
  • logoSize: Proportion of QR size (0.1–0.4, default 0.3)
  • Use H error correction for logos (auto-bumped from L)

Output Formats

Format Use Case
png Default, universal support
svg Scalable, small file size
jpeg Compressed, no transparency

Example Presets

Minimal dark:

{"dotStyle": "dots", "dotColor": "#000000", "backgroundColor": "#f5f5f5"}

Vibrant gradient:

{"dotStyle": "rounded", "gradient": {"type": "linear", "colors": ["#f093fb", "#f5576c"]}}

Branded with logo:

{"dotStyle": "classy-rounded", "dotColor": "#1e3a5f", "logoPath": "./logo.png", "logoSize": 0.25, "errorCorrectionLevel": "H"}

Neon on dark:

{"dotStyle": "dots", "dotColor": "#00ff88", "backgroundColor": "#0a0a0a", "cornerColor": "#ff0080"}

Error Correction

Level Recovery Best For
L 7% Maximum data, no logo
M 15% General use (default)
Q 25% Minor obstruction expected
H 30% Logos, harsh environments

Tips

  1. Contrast matters — Ensure sufficient contrast between dots and background for reliable scanning
  2. Test scanning — Always verify styled QR codes scan correctly
  3. Logo size — Keep logos under 30% for reliable scanning
  4. High error correction — Use Q or H when adding logos or artistic effects