# <camera>

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

Category: Media. Uses camera, location.

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

```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>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/camera-light.webp), [dark](https://hypeapps.dev/img/tags/camera-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `controls` | Show control bar | `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. | `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. |  |
| `overlay` | Camera overlay (crosshair, none) | `none` |
| `preview` | Show live preview | `true` |
| `resolution` | Camera resolution (low, medium, high, max) | `high` |
| `shutter` | Show capture button | `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.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<audio>`](https://hypeapps.dev/docs/reference/audio.md): A compact audio player bar with play, a progress track and the track's title and artist.
- [`<canvas>`](https://hypeapps.dev/docs/reference/canvas.md): A drawing surface for finger or stylus, with a pen, eraser and color toolbar; it saves as a PNG.
- [`<file-picker>`](https://hypeapps.dev/docs/reference/file-picker.md): Opens the device's photo, video or file picker (or the camera) and puts the chosen file in a variable.
- [`<img>`](https://hypeapps.dev/docs/reference/img.md): Shows a picture from a URL or the app's files, sized and cropped by its style.
- [`<layer>`](https://hypeapps.dev/docs/reference/layer.md): Declares one layer of a drawing surface: a locked picture to trace over, and a layer to paint on.
- [`<lottie>`](https://hypeapps.dev/docs/reference/lottie.md): Plays a Lottie vector animation from a JSON file; taps and media commands control it.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
