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.

Source on GitHub

Open on your phone: type a link, the code follows

Download PNG Download SVG
Two-step sign-in: the code, and the key as text for who cannot scan

Scan it with your authenticator app, or type this key:

JBSW Y3DP EHPK 3PXP
A logo at the middle (the error correction goes up to H), colors, sizes
Code

API

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".

PropertyAttributeTypeDefaultDescription
valuevaluestringThe text or link to encode. Empty: nothing is drawn.
eccecc reflectsL | M | Q | HMError 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.
sizesize reflectsstringmdThe side, quiet zone included: xs (4rem), sm (6rem), md (8rem), lg (12rem), xl (16rem), or any CSS length.
quietZonequiet-zonenumber4The light margin around the code, in modules (the standard asks for 4; 2 reads well on a plain background).
colorcolorstringThe modules' color: a palette color or any CSS color (default black). Keep it dark.
backgroundbackgroundstringThe background, any CSS color (default white). Keep it light.
labellabelstringIts 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.
EventDescription
ray-errorThe value does not fit in a QR code (over about 2,900 bytes at L); nothing is drawn.
SlotDescription
(default)A logo for the middle (an <img> or an <svg>), on the background color, 22 % of the code's side.
PartDescription
codeThe <svg>.
backgroundThe background rectangle.
modulesThe path of the dark modules.
logoThe logo's box.

Texts

What it writes itself, in English; setStrings() translates them (Getting started: Languages).

KeyEnglish
qr.labelQR code