← All Components
<mth-camera-capture>
Accessible camera capture component wrapping MediaDevices.getUserMedia with graceful JSDOM/SSR fallback.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-camera-capture>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/rtc/camera-capture"></script>
<mth-camera-capture facing-mode="user" mime-type="image/png"></mth-camera-capture>import '@methane-ui/rtc/camera-capture';
import '@methane-ui/react';
export function Example() {
return <mth-camera-capture facing-mode="user" mime-type="image/png"></mth-camera-capture>;
}<script setup lang="ts">
import '@methane-ui/rtc/camera-capture';
</script>
<template>
<mth-camera-capture facing-mode="user" mime-type="image/png"></mth-camera-capture>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/rtc/camera-capture';
import { MthCameraCaptureDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthCameraCaptureDirective],
template: `<mth-camera-capture facing-mode="user" mime-type="image/png"></mth-camera-capture>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/rtc/camera-capture';
import MthCameraCapture from '@methane-ui/svelte/MthCameraCapture.svelte';
</script>
<MthCameraCapture facing-mode="user" mime-type="image/png"></MthCameraCapture>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
facingMode | facing-mode | 'user' | 'environment' | "user" | Preferred camera facing mode (user or environment). |
deviceId | device-id | string | "" | Explicit video input device ID. |
mimeType | mime-type | string | "image/png" | Snapshot image MIME type. |
quality | quality | number | 0.92 | Encoder quality (0..1) for lossy image formats. |
disabled | disabled | boolean | false | Disables camera controls. |
label | label | string | "" | Accessible region label. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-capture | { dataUrl: string; width: number; height: number } | Fired when a still frame snapshot is captured. |
mth-permission-change | { status: unknown } | Fired when camera permission or stream status changes. |
mth-device-change | { deviceId: string } | Fired when the selected camera device changes. |
mth-error | { message: string } | Fired when camera access or capture encounters an error. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | Focus is on Start/Stop or Capture button | Triggers camera stream toggle or captures a snapshot |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-camera-capture.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(active), :state(denied), :state(unsupported). | Conformance suite |
| i18n | Routes 15 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |