# Mic Selector Example

> Example implementation of mic selector.

A shadcn/ui block from the [@ai-elements](https://ai-sdk.dev/elements) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/ai-elements/example-mic-selector).

- Page, with a live preview: https://shadcn.exchange/r/ai-elements/example-mic-selector
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/ai-elements/example-mic-selector-light-092af48d0d113ecc.png
- Registry item: https://ai-sdk.dev/elements/api/registry/example-mic-selector.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ai-sdk.dev/elements/api/registry/example-mic-selector.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `https://elements.ai-sdk.dev/mic-selector.json`

## Files

### `registry/default/examples/mic-selector.tsx`

```tsx
"use client";

import {
  MicSelector,
  MicSelectorContent,
  MicSelectorEmpty,
  MicSelectorInput,
  MicSelectorItem,
  MicSelectorLabel,
  MicSelectorList,
  MicSelectorTrigger,
  MicSelectorValue,
} from "@/components/ai-elements/mic-selector";

const handleOpenChange = (open: boolean) => {
  console.log("MicSelector is open?", open);
};

const handleValueChange = (newValue: string) => {
  console.log("MicSelector value:", newValue);
};

const Example = () => (
  <div className="flex size-full flex-col items-center justify-center gap-4">
    <MicSelector
      onOpenChange={handleOpenChange}
      onValueChange={handleValueChange}
    >
      <MicSelectorTrigger className="w-full max-w-sm">
        <MicSelectorValue />
      </MicSelectorTrigger>
      <MicSelectorContent>
        <MicSelectorInput />
        <MicSelectorEmpty />
        <MicSelectorList>
          {(devices) =>
            devices.map((device) => (
              <MicSelectorItem key={device.deviceId} value={device.deviceId}>
                <MicSelectorLabel device={device} />
              </MicSelectorItem>
            ))
          }
        </MicSelectorList>
      </MicSelectorContent>
    </MicSelector>
  </div>
);

export default Example;
```
