This library is built for the purpose generating QR codes with a logo and styling.
Installations
npm install ngx-qrcode-styling
Developer Guide
Typescript
No
Module System
ESM
Node Version
18.16.0
NPM Version
9.5.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
HTML (97.82%)
TypeScript (1.95%)
SCSS (0.23%)
Developer
Download Statistics
Total Downloads
77,437
Last Day
163
Last Week
639
Last Month
4,313
Last Year
43,675
GitHub Statistics
22 Stars
7 Commits
9 Forks
2 Watching
4 Branches
1 Contributors
Bundle Size
65.06 kB
Minified
17.42 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.3.2
Package Id
ngx-qrcode-styling@1.3.2
Unpacked Size
291.65 kB
Size
53.21 kB
File Count
20
NPM Version
9.5.1
Node Version
18.16.0
Publised On
26 Nov 2023
Total Downloads
Cumulative downloads
Total Downloads
77,437
Last day
25.4%
163
Compared to previous day
Last week
-38.3%
639
Compared to previous week
Last month
-13.3%
4,313
Compared to previous month
Last year
87.8%
43,675
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
2
ngx-qrcode-styling
This library is built for the purpose generating QR codes with a logo and styling.
Demo on the Github or Stackblitz or Codesandbox
Generating styled QRcodes Online
Installation
Install ngx-qrcode-styling
from npm
:
1npm install ngx-qrcode-styling@<version> --save
Add wanted package to NgModule imports:
1import { NgxQrcodeStylingModule } from 'ngx-qrcode-styling'; 2 3@NgModule({ 4 imports: [ 5 NgxQrcodeStylingModule 6 ] 7})
Add component to your page:
1import { Options } from 'ngx-qrcode-styling'; 2 3export class AppComponent { 4 public config: Options = { 5 width: 300, 6 height: 300, 7 data: "https://www.facebook.com/", 8 image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg", 9 margin: 5, 10 dotsOptions: { 11 color: "#1977f3", 12 type: "dots" 13 }, 14 backgroundOptions: { 15 color: "#ffffff", 16 }, 17 imageOptions: { 18 crossOrigin: "anonymous", 19 margin: 0 20 } 21 }; 22}
1<ngx-qrcode-styling [config]="config"></ngx-qrcode-styling>
Multi input
1<ngx-qrcode-styling 2 #qrcode 3 [config]="config" 4 [type]="'canvas'" 5 [shape]="'square'" 6 [width]="200" 7 [height]="200" 8 [margin]="5" 9 [data]="'Angular QRCode'" 10 [image]="'https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg'"> 11</ngx-qrcode-styling>
1import { NgxQrcodeStylingComponent, Options } from 'ngx-qrcode-styling'; 2 3export class AppComponent { 4 @ViewChild('qrcode', { static: false }) public qrcode!: NgxQrcodeStylingComponent; 5 6 onUpdate(): void { 7 this.qrcode.update(this.qrcode.config, { 8 // height: 300, 9 // width: 300, 10 frameOptions: { 11 height: 600, 12 width: 600, 13 }, 14 ... 15 }).subscribe((res) => { 16 // TO DO something! 17 }); 18 } 19 20 onDownload(): void { 21 this.qrcode.download("file-name.png").subscribe((res) => { 22 // TO DO something! 23 }); 24 } 25}
Element reference
1<div #canvas></div>
1import { NgxQrcodeStylingService, Options } from 'ngx-qrcode-styling'; 2 3export class AppComponent implements AfterViewInit { 4 @ViewChild("canvas", { static: false }) canvas: ElementRef; 5 public config: Options = {...}; 6 7 constructor(private qrcode: NgxQrcodeStylingService) {} 8 9 ngAfterViewInit(): void { 10 // Create QRCode by Service and ElementRef 11 this.qrcode.create(this.config, this.canvas.nativeElement).subscribe((res) => { 12 // TO DO something! 13 }); 14 } 15}
Element id
1<div id="canvas"></div>
1import { NgxQrcodeStylingService, Options } from 'ngx-qrcode-styling'; 2 3export class AppComponent implements AfterViewInit { 4 public config: Options = {...}; 5 6 constructor(private qrcode: NgxQrcodeStylingService) {} 7 8 ngAfterViewInit(): void { 9 // Create QRCode by Service and HTMLElement 10 this.qrcode.create(this.config, document.getElementById('canvas')).subscribe((res) => { 11 // TO DO something! 12 }); 13 } 14}
Using a template
1import { Options } from 'ngx-qrcode-styling'; 2 3export class AppComponent { 4 public config: Options = { 5 template: 'bitcoin', 6 ... 7 } 8}
Or
1<ngx-qrcode-styling [template]="'bitcoin'" [data]="'ngx-qrcode-styling'"></ngx-qrcode-styling>
Using a frame
1import { Options } from 'ngx-qrcode-styling'; 2 3export class AppComponent { 4 public config: Options = { 5 frameOptions: { 6 style: 'F_036', 7 width: 300, 8 height: 300, 9 x: 50, 10 y: 50 11 } 12 ... 13 } 14}
Or
1<ngx-qrcode-styling 2 [template]="'bitcoin'" 3 [data]="'ngx-qrcode-styling'" 4 [width]="280" 5 [height]="280" 6 [image]="'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/BTC_Logo.svg/60px-BTC_Logo.svg.png'" 7 [frameOptions]="{style: 'F_036', height: 300, width: 300, x: 60, y: 60}"> 8</ngx-qrcode-styling>
API Documentation
Input
frameOptions :hammer_and_wrench:
Property | Type | Default Value | Description |
---|---|---|---|
(type) | canvas , svg | canvas | The type of the element that will be rendered |
(shape) | square , circle | square | The type of the element that will be rendered |
(width) | number | 300 | Size of canvas |
(height) | number | 300 | Size of canvas |
(margin) | number | 0 | Margin around canvas |
(data) | string | The date will be encoded to the QR code | |
(image) | string | The image will be copied to the center of the QR code | |
(scale) | number | 0 | Scale qrcode |
(rotate) | number | 0 | Rotate qrcode |
(zIndex) | 1 , 2 | 2 | QR position is before or after |
(template) | default , ocean , sunflower , luxury , bitcoin , starbucks , angular , facebook , beans , green , sky , mosaic , coffee , vintage , stamp , chess , jungle , arabic , tea , grape | default | The design of the element that will be rendered |
(frameOptions) | object | Options will be passed to qrcode-generator lib | |
(qrOptions) | object | Options will be passed to qrcode-generator lib | |
(imageOptions) | object | Specific image options, details see below | |
(dotsOptions) | object | Dots styling options | |
(cornersSquareOptions) | object | Square in the corners styling options | |
(backgroundOptions) | object | QR background styling options |
Event
Component and Service :hammer_and_wrench:
Field | Description | Type | Default |
---|---|---|---|
(create) | status | AsyncSubject | - |
(update) | status | AsyncSubject | - |
(download) | status | AsyncSubject | - |
Models in Config
Options
1export declare type Options = { 2 type?: DrawType; 3 shape?: ShapeType; 4 width?: number; 5 height?: number; 6 margin?: number; 7 data?: string; 8 image?: string; 9 scale?: number; 10 rotate?: number; 11 template?: string; 12 zIndex?: 1 | 2; 13 frameOptions?: { 14 style?: string; 15 height?: number; 16 width?: number; 17 x?: number; 18 y?: number; 19 texts?: UnknownObject[]; // SVG Attribute reference 20 contents?: UnknownObject[]; // SVG Attribute reference 21 containers?: UnknownObject[]; // SVG Attribute reference 22 }; 23 qrOptions?: { 24 typeNumber?: TypeNumber; 25 mode?: Mode; 26 errorCorrectionLevel?: ErrorCorrectionLevel; 27 }; 28 imageOptions?: { 29 hideBackgroundDots?: boolean; 30 imageSize?: number; 31 crossOrigin?: string; 32 margin?: number; 33 }; 34 dotsOptions?: { 35 type?: DotType; 36 color?: string; 37 gradient?: Gradient; 38 }; 39 cornersSquareOptions?: { 40 type?: CornerSquareType; 41 color?: string; 42 gradient?: Gradient; 43 }; 44 cornersDotOptions?: { 45 type?: CornerDotType; 46 color?: string; 47 gradient?: Gradient; 48 }; 49 backgroundOptions?: { 50 round?: number; 51 color?: string; 52 gradient?: Gradient; 53 }; 54};
Model Details
frameOptions
Property | Type | Default Value |
---|---|---|
style | F_020 , ... F_080 , FE_001 , ... FE_XXX | F_020 |
width | number(0 - max ) | 300 |
height | number(0 - max ) | 300 |
x | number(0 - max ) | 50 |
y | number(0 - max ) | 50 |
texts | UnknownObject[] | - |
contents | UnknownObject[] | - |
containers | UnknownObject[] | - |
qrOptions
Property | Type | Default Value |
---|---|---|
typeNumber | 0 ,40 | 0 |
mode | Numeric , Alphanumeric , Byte , Kanji | |
errorCorrectionLevel | L , M , Q , H | Q |
imageOptions
Property | Type | Default Value | Description |
---|---|---|---|
hideBackgroundDots | boolean | true | Hide all dots covered by the image |
imageSize | number | 0.4 | Coefficient of the image size. Not recommended to use ove 0.5. Lower is better |
margin | number | 0 | Margin of the image in px |
crossOrigin | anonymous , use-credentials | Set "anonymous" if you want to download QR code from other origins. |
dotsOptions
Property | Type | Default Value | Description |
---|---|---|---|
color | string | #000 | Color of QR dots |
gradient | object | Gradient of QR dots | |
type | rounded ,dots , classy , classy-rounded , square , extra-rounded | square | Style of QR dots |
backgroundOptions
Property | Type | Default Value |
---|---|---|
color | string | #fff |
gradient | object |
cornersSquareOptions
Property | Type | Default Value | Description |
---|---|---|---|
color | string | Color of Corners Square | |
gradient | object | Gradient of Corners Square | |
type | dot , square , extra-rounded | Style of Corners Square |
cornersDotOptions
Property | Type | Default Value | Description |
---|---|---|---|
color | string | Color of Corners Dot | |
gradient | object | Gradient of Corners Dot | |
type | dot , square | Style of Corners Dot |
Gradient
dotsOptions.gradient
backgroundOptions.gradient
cornersSquareOptions.gradient
cornersDotOptions.gradient
Property | Type | Default Value | Description |
---|---|---|---|
type | linear , radial | linear | Type of gradient spread |
rotation | number | 0 | Rotation of gradient in radians (Math.PI === 180 degrees) |
colorStops | array of objects | Gradient colors. Example [{ offset: 0, color: 'blue' }, { offset: 1, color: 'red' }] |
Gradient colorStops
dotsOptions.gradient.colorStops[]
backgroundOptions.gradient.colorStops[]
cornersSquareOptions.gradient.colorStops[]
cornersDotOptions.gradient.colorStops[]
Property | Type | Default Value | Description |
---|---|---|---|
offset | 0 , 1 | Position of color in gradient range | |
color | string | Color of stop in gradient range |
Support versions
Support versions | |
---|---|
Angular 16 | 1.3.2 |
Angular 6 | 1.3.1 |
Author Information
Author Information | |
---|---|
Author | DaiDH |
Phone | +84845882882 |
Country | Vietnam |
To make this library more complete, please donate to me if you can!
Bitcoin | Paypal | MBBank |
---|---|---|
Beerware License. Copyright (c) 2021 DaiDH
No vulnerabilities found.
No security vulnerabilities found.
Other packages similar to ngx-qrcode-styling
ngx-qrcode-styling-his
This library is built for the purpose for generating QR codes with a logo and styling.
ngx-qrcode-styling-angular
This library is built for the purpose for generating QR codes with a logo and styling.
blinked-qr
This library is built for the purpose for dynamic generating QR codes with a logo and styling.