Mic selector
Pick the microphone and see that it hears you, with clear words when access is not granted, blocked, or there is none.
On this page
Your real microphones, with a live level on the one in use. Asks for access first.
Installation
Usage
import { MicSelector } from "@/components/ui/chatcn/mic-selector"
<MicSelector value={deviceId} onValueChange={setDeviceId} />Reads the inputs and the permission state from the browser, and keeps up when a device is plugged in or out. The trigger shows the device and its level; the menu lists every input with a live meter on the one in use, so a muted headset is obvious before the call. The microphone is only open while the menu is. Before access it asks in words with an Allow button; if access is blocked or there is no microphone it says what to do. Pass devices, permission and levels to render it without the browser, for previews and tests. Replaces AI Elements' MicSelector.
Examples
States
Hearing you, a quiet device, not asked yet, blocked, and no microphone.
Props
| Prop | Type | Notes |
|---|---|---|
value, defaultValue, onValueChange | string | A device id |
devices | MicDevice[] | { deviceId, label }. Read from the browser when left out |
permission | "prompt" | "granted" | "denied" | Read from the browser when left out |
levels | Record<string, number> | Fixed levels from 0 to 1, for previews |
onPermissionChange | (permission) => void | After the Allow button |
size, disabled | ||
labels | Partial<MicSelectorLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Enter or Space on the trigger | Open the list |
| Arrow keys, Enter | Choose a microphone |
Accessibility
- The level is a meter with its value, not only lit bars.
- Blocked and missing microphones are explained in text with the fix.
- The trigger names the microphone in use.