Skip to content
Sign upPro
VoiceMic selectorMenu

Mic selector

Pick the microphone and see that it hears you, with clear words when access is not granted, blocked, or there is none.

Your real microphones, with a live level on the one in use. Asks for access first.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/mic-selector.json

Usage

tsx
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

PropTypeNotes
value, defaultValue, onValueChangestringA device id
devicesMicDevice[]{ deviceId, label }. Read from the browser when left out
permission"prompt" | "granted" | "denied"Read from the browser when left out
levelsRecord<string, number>Fixed levels from 0 to 1, for previews
onPermissionChange(permission) => voidAfter the Allow button
size, disabled
labelsPartial<MicSelectorLabels>Every string, for translation

Keyboard

KeyAction
Enter or Space on the triggerOpen the list
Arrow keys, EnterChoose 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.