# j-QRCode

> This component creates a QR code. It includes the [QRCode library](https://davidshimjs.github.io/qrcodejs/).

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 0b671644d91eda34269f8e120283b93e071506f44f74151b25be9a8c058aac1c
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

This component creates a QR code. It includes the [QRCode library](https://davidshimjs.github.io/qrcodejs/).


__Configuration__:

- `width {Number}` a default image width (default: `128`)
- `height {Number}` a default image height (default: `128`)
- `fg {String}` a foreground color (default: `#000000`)
- `bg {String}` a background color (default: `#FFFFFF`)
- `delay {Number}` a small delay for code generating (default: `200`)

__How to generate QR Code?__

```js
var opt = {};
opt.text = 'https://www.totaljs.com';
// opt.width {Number}
// opt.height {Number}
// opt.fg {String}
// opt.bg {String}
opt.callback = function(base64) {
	console.log(base64);
};
SETTER('qrcode/create', opt);
```

Use it with `<ui-component name="qrcode">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="qrcode" config="width:200;height:200"></ui-component>

<script>

	ON('ready', function() {
		var opt = {};
		opt.text = 'https://totaljs.com';
		opt.callback = function(base64) {
			var img = document.createElement('IMG');
			img.setAttribute('src', base64);
			document.body.append(img);
		};
		SETTER('qrcode/create', opt);
	});

</script>
```
