# VoiceInput

> A mic button that opens into a recording panel: a live waveform painted from amplitude levels you supply, a stopwatch, the transcript as it arrives, and a cross and a check to throw it away or keep it.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: AI Chat
- Tags: ai, chat, voice, waveform, input
- Types: `VoiceInputProps`
- Docs: https://fancy-ui.rama.app/docs/components/voice-input
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/voice-input

## Import

```tsx
import { VoiceInput } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `active` | `boolean` | `false` | Whether a recording is in progress (bindable). Every button writes through it; setting it from outside opens or closes the panel without firing a callback |
| `transcript` | `string` | `""` | Live text pushed by the consumer as their recogniser produces it, rendered muted under the waveform; a growing string grows in place |
| `samples` | `ArrayLike<number>` | — | Amplitude levels in 0..1 bridged from your own audio pipeline, one entry per bar. The component never opens a microphone itself |
| `demo` | `boolean` | `false` | Draw a deterministic synthetic wave when no samples arrive, so the panel is legible on a page with no audio behind it. Real samples always win |
| `onStart` | `() => void` | — | Called when the mic button starts a recording |
| `onStop` | `() => void` | — | Called when the check ends the recording and keeps the transcript |
| `onCancel` | `() => void` | — | Called when the cross abandons the recording |
| `height` | `number` | `48` | Waveform height in CSS pixels, clamped to 16..240 |
| `color` | `string` | `var(--ft-voice-color, currentColor)` | Any CSS colour for the bars, including a var() or currentColor — written onto the canvas as its CSS color and read back resolved, because a 2D context understands neither |
| `sound` | `boolean` | `false` | Plays open on start, close on cancel and select on a confirmed recording, once the user has enabled sound |

## Example

No React example is published for this component yet: start from the import above and the props table. The full examples are Svelte-only, on https://fancy-ui.rama.app/docs/components/voice-input.md.
