1. Reference
  2. Media

<camera>

A live camera viewfinder with a shutter; the photo's path goes into a variable.

Media Uses cameraUses location

This tag needs a camera, so try it on your phone.

camera.ham
<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>
The snippet drawn by Hype Apps on a phone, in light mode The snippet drawn by Hype Apps on a phone, in dark mode
This snippet as Hype Apps draws it on a phone. It follows this page's light or dark theme.

Attributes

NameWhat it doesDefault
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

NameWhat 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

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

This page is also Markdown, and all of HAM is in llms.txt.