interface Options {
    document: Document;
    imageTools?: {
        toDataURL: (url: string | Buffer | Blob) => Promise<string>;
        getSize: (
            src: string | Buffer | Blob,
            crossOrigin?: string,
        ) => Promise<{ width: number; height: number }>;
    };
    data: string;
    image?: string
    | Buffer
    | Blob;
    shape: "square" | "circle";
    qrOptions: {
        typeNumber: TypeNumber;
        mode?: "numeric" | "alphanumeric" | "byte" | "kanji" | "unicode";
        errorCorrectionLevel: "L" | "M" | "Q" | "H";
    };
    imageOptions: {
        mode: "center"
        | "overlay"
        | "background";
        fill: { color: string; gradient?: Gradient };
        imageSize: number;
        margin: number;
        crossOrigin?: string;
    };
    dotsOptions: {
        size: number;
        color: string;
        gradient?: Gradient;
        type: | "dot"
        | "random-dot"
        | "rounded"
        | "extra-rounded"
        | "vertical-line"
        | "horizontal-line"
        | "classy"
        | "classy-rounded"
        | "square"
        | "small-square"
        | "tiny-square"
        | "diamond";
    };
    cornersSquareOptions?: {
        color?: string;
        gradient?: Gradient;
        type?: | "dot"
        | "extra-rounded"
        | "classy"
        | "square"
        | "outpoint"
        | "inpoint";
    };
    cornersDotOptions?: {
        color?: string;
        gradient?: Gradient;
        type?: | "dot"
        | "extra-rounded"
        | "classy"
        | "square"
        | "heart"
        | "outpoint"
        | "inpoint";
    };
    backgroundOptions?: | false
    | { round?: number; color?: string; gradient?: Gradient; margin?: number };
    stringToBytesFuncs?: { [encoding: string]: (s: string) => number[] };
}

Properties

document: Document

Use a custom DOM domplementation

imageTools?: {
    toDataURL: (url: string | Buffer | Blob) => Promise<string>;
    getSize: (
        src: string | Buffer | Blob,
        crossOrigin?: string,
    ) => Promise<{ width: number; height: number }>;
}

Use a custom image fetching & serializaton implementation

data: string

The data will be encoded in the QR code

image?: string | Buffer | Blob

The image will be copied to the center of the QR code

shape: "square" | "circle"

QR code shape

ShapeType.square
qrOptions: {
    typeNumber: TypeNumber;
    mode?: "numeric" | "alphanumeric" | "byte" | "kanji" | "unicode";
    errorCorrectionLevel: "L" | "M" | "Q" | "H";
}

Options will be passed to @liquid-js/qrcode-generator lib

Type declaration

  • typeNumber: TypeNumber
  • Optionalmode?: "numeric" | "alphanumeric" | "byte" | "kanji" | "unicode"
  • errorCorrectionLevel: "L" | "M" | "Q" | "H"
    ErrorCorrectionLevel.Q
    
imageOptions: {
    mode: "center" | "overlay" | "background";
    fill: { color: string; gradient?: Gradient };
    imageSize: number;
    margin: number;
    crossOrigin?: string;
}

Type declaration

  • mode: "center" | "overlay" | "background"

    Image mode

    ImageMode.center
    
  • fill: { color: string; gradient?: Gradient }

    Fill blank areas of the code with selected color

    • color: string

      Color of QR dots

      "rgba(255,255,255,0.75)"
      
    • Optionalgradient?: Gradient

      Gradient of Corners Dot

  • imageSize: number

    Coefficient of the image size

    0.4
    
  • margin: number

    Margin of the image (in blocks)

    0
    
  • OptionalcrossOrigin?: string
dotsOptions: {
    size: number;
    color: string;
    gradient?: Gradient;
    type:
        | "dot"
        | "random-dot"
        | "rounded"
        | "extra-rounded"
        | "vertical-line"
        | "horizontal-line"
        | "classy"
        | "classy-rounded"
        | "square"
        | "small-square"
        | "tiny-square"
        | "diamond";
}

Type declaration

  • size: number

    QR dot size (in pixels)

    10
    
  • color: string

    Color of QR dots

    "#000"
    
  • Optionalgradient?: Gradient

    Gradient of QR dots

  • type:
        | "dot"
        | "random-dot"
        | "rounded"
        | "extra-rounded"
        | "vertical-line"
        | "horizontal-line"
        | "classy"
        | "classy-rounded"
        | "square"
        | "small-square"
        | "tiny-square"
        | "diamond"

    Style of QR dots

    DotType.square
    
cornersSquareOptions?: {
    color?: string;
    gradient?: Gradient;
    type?:
        | "dot"
        | "extra-rounded"
        | "classy"
        | "square"
        | "outpoint"
        | "inpoint";
}

Corners Square options, omitted values match dots

Type declaration

  • Optionalcolor?: string

    Color of Corners Square

  • Optionalgradient?: Gradient

    Gradient of Corners Square

  • Optionaltype?: "dot" | "extra-rounded" | "classy" | "square" | "outpoint" | "inpoint"

    Style of Corners Square

cornersDotOptions?: {
    color?: string;
    gradient?: Gradient;
    type?:
        | "dot"
        | "extra-rounded"
        | "classy"
        | "square"
        | "heart"
        | "outpoint"
        | "inpoint";
}

Corners Dot options, omitted values match squares

Type declaration

  • Optionalcolor?: string

    Color of Corners Dot

  • Optionalgradient?: Gradient

    Gradient of Corners Dot

  • Optionaltype?: "dot" | "extra-rounded" | "classy" | "square" | "heart" | "outpoint" | "inpoint"

    Style of Corners Dot

backgroundOptions?:
    | false
    | { round?: number; color?: string; gradient?: Gradient; margin?: number }

QR background styling options, false to disable background

Type declaration

  • false
  • { round?: number; color?: string; gradient?: Gradient; margin?: number }
    • Optionalround?: number

      Background roundnes, from 0 (square) to 1 (circle)

    • Optionalcolor?: string

      Background color

    • Optionalgradient?: Gradient

      Background Gradient

    • Optionalmargin?: number

      Margin (in blocks) between background and the QR code

      0
      
stringToBytesFuncs?: { [encoding: string]: (s: string) => number[] }

import { stringToBytesFuncs } from "@liquid-js/qr-code-styling/kanji"; to add Kanji support