> This page is for Browser SDK, version v4 (default).
> For other versions, use one of these documentation indexes:
> - v4 (default): https://signalwire.com/docs/browser-sdk/v4/llms.txt
> - v3: https://signalwire.com/docs/browser-sdk/v3/llms.txt
> - v2: https://signalwire.com/docs/browser-sdk/v2/llms.txt

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# sw-local-camera

Aspect-ratio-aware preview tile for the local camera, with a
"camera off" placeholder when video is muted or the stream is missing.

```html
<sw-call-provider token="YOUR_GUEST_TOKEN">
  <sw-local-camera></sw-local-camera>
</sw-call-provider>
```

Designed for small picture-in-picture-style previews — typically slotted
into `<sw-ui-call-layout>`'s `floating-video` slot or used standalone in
a settings panel. The element reads `getSettings()` on the active video
track to detect the natural orientation (landscape, portrait, or square)
and rewrites `--sw-local-camera-aspect` so its container hugs the track.

Input precedence (most specific wins): **`.stream` / `.videoMuted` >
`.call` > context**. Any of `.stream` and `.videoMuted` can be set
independently — for example, you can supply an explicit `stream` from a
"join" preview screen while still letting `videoMuted` come from
`devicesContext`.

The `mirror` attribute reflects to the host so it can be styled with
`:host([mirror])` and is the natural default for selfie cameras.

*Class: `SwLocalCamera` · Module: `packages/web-components/src/components/sw-local-camera.ts`*

## class: `SwLocalCamera`, `sw-local-camera`

### Fields

**`stream`** `MediaStream | null` — default: null

Explicit stream — highest precedence.

---

**`videoMuted`** `boolean | undefined`

Explicit muted flag — overrides devicesContext.videoMuted.

---

**`call`** `Call | undefined`

Explicit Call — used when `.stream` is not set. Bypasses context.

---

**`mirror`** `boolean` — default: false

`mirror` field.

---

### Attributes

| Name          | Field      | Inherited From |
| ------------- | ---------- | -------------- |
| `video-muted` | videoMuted |                |
| `mirror`      | mirror     |                |
| `call`        | call       |                |

### CSS Properties

| Name                       | Default | Description                                                                                                                             |
| -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `--sw-local-camera-aspect` | `16/9`  | Aspect ratio of the tile. Automatically rewritten to match the active track's orientation (e.g. \`9 / 16\` for portrait phone cameras). |

### CSS Parts

| Name          | Description                                                                                              |
| ------------- | -------------------------------------------------------------------------------------------------------- |
| `video`       | The internal \`\<video>\` element rendering the local stream (\`autoplay\`, \`muted\`, \`playsinline\`). |
| `placeholder` | The "camera off" overlay shown while video is muted or no stream is bound.                               |

---