<camera>
A live camera viewfinder with a shutter; the photo's path goes into a variable.
This tag needs a camera, so try it on your phone.
<column style="gap-12">
<camera name="photo"
facing="back"
style="h-320 rounded-xl"/>
<text style="muted text-sm">Point at the receipt and tap the shutter.</text>
</column>
Attributes
| Name | What it does | Default |
|---|---|---|
controls |
Show control bar boolean |
true |
facing |
Camera direction back, front |
back |
flash |
Flash mode off, auto, on, torch |
off |
keep |
Move each capture into the app's own storage and publish a media: reference that survives. false leaves it in the OS cache. boolean |
true |
loading |
Loading indicator style spinner, none, text |
spinner |
name |
Variable set to the captured photo path on every capture, like <file-picker name>. The capture event also carries \$event.value. string |
|
overlay |
Camera overlay crosshair, none |
none |
preview |
Show live preview boolean |
true |
resolution |
Camera resolution low, medium, high, max |
high |
shutter |
Show capture button boolean |
true |
Events
| Name | What it does |
|---|---|
on-capture |
Upload endpoint: after each capture the photo is POSTed there as multipart (field = name, default image), then `uploaded` fires. Not an action: use action-capture / @on.capture for statements. |
on-error |
Statements run when the camera cannot start or a capture fails (same as action-error / @on.error). \$event.error is denied, unavailable or failed. |
Readings
| Name | What it does |
|---|---|
filename |
The last capture's file name. |
size |
The last capture's size in bytes. |
type |
The capture's MIME type (image/jpeg). |
value |
The last capture's path; empty before one. |
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.