QR code also QR, Barcode, 2D code
A QR code of a text or a link (to open on a phone, pair a device, set up two-step sign-in), drawn as one SVG path: sharp at any size and in print. Its own encoder, no dependencies (about 3 KB gzip, only where imported); a logo at the middle; toSVG() and toPNG() to save or share it.
Scan it with your authenticator app, or type this key:
JBSW Y3DP EHPK 3PXPAPI
For AI agents: this API as Markdown, or every component in llms-full.txt.
<ray-qr> · RayQr
Dark on light whatever the theme (scanners need it): --ray-qr-color and --ray-qr-background (or color and background) change them, keep the modules darker. The smallest version that holds the text is used, and the error correction raised while it still fits (a stronger code, same size). Text: UTF-8, as phones read it. The encoder alone: import { qrMatrix } from "@raylang/elements/qr".
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | The text or link to encode. Empty: nothing is drawn. | |
ecc | ecc reflects | L | M | Q | H | M | Error correction, the least used (raised when it costs no size): L recovers 7 % of the code, M 15 %, Q 25 %, H 30 %. With a logo, always H. |
size | size reflects | string | md | The side, quiet zone included: xs (4rem), sm (6rem), md (8rem), lg (12rem), xl (16rem), or any CSS length. |
quietZone | quiet-zone | number | 4 | The light margin around the code, in modules (the standard asks for 4; 2 reads well on a plain background). |
color | color | string | The modules' color: a palette color or any CSS color (default black). Keep it dark. | |
background | background | string | The background, any CSS color (default white). Keep it light. | |
label | label | string | Its accessible name (default "QR code", translated). Say what it is for ("Scan to open on your phone"), and show the link or code as text too: not everyone can scan. |
| Event | Description |
|---|---|
ray-error | The value does not fit in a QR code (over about 2,900 bytes at L); nothing is drawn. |
| Slot | Description |
|---|---|
| (default) | A logo for the middle (an <img> or an <svg>), on the background color, 22 % of the code's side. |
| Part | Description |
|---|---|
code | The <svg>. |
background | The background rectangle. |
modules | The path of the dark modules. |
logo | The logo's box. |
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).
| Key | English |
|---|---|
qr.label | QR code |