<qr-scanner>
A live camera viewfinder that reads QR codes and runs on-scan with the code it found.
Aliases
Reset to canonicalThis tag has more than one name. Every spelling is the same tag, so write whichever feels natural. Pick one and every example on this page uses it.
This tag needs a camera, so try it on your phone.
<column style="gap-12">
<qr-scanner id="scan"
style="h-320 rounded-lg"
on-scan="$code = $event.value"/>
<text style="muted">Point the camera at a ticket's QR code.</text>
</column>
Attributes
| Name | What it does | Default |
|---|---|---|
cooldown |
Seconds before the same code can fire again. Unset: each code fires once while the scanner is on screen. number |
|
facing |
Which camera. back, front |
back |
frame |
Draw the corner brackets showing where to hold the code. boolean |
true |
torch |
Start with the torch on. boolean |
false |
Commands
| Name | What it does |
|---|---|
pause |
Stop reading codes (the preview stays); \$id.scanning goes false. |
reset |
Forget the codes already read, so each can fire again. |
resume |
Read codes again. |
torch |
Toggle the torch, or set it; \$id.torch follows. |
Events
| Name | What it does |
|---|---|
on-scan |
Statements to run when a code is read (same as @on.scan / action-scan): on-scan="auth:pair:\$event.query.code". |
Readings
| Name | What it does |
|---|---|
scanning |
Whether codes are being read. |
torch |
Whether the torch is on. |
value |
The last code read. |
Any tag also takes gestures: @on.tap, @on.longpress, @on.doubletap and @on.swipeleft (and right, up and down). @click runs on a tap too.