Skip to content
Sign upPro
ComposerVoice first composerMenu

Voice first composer (Pro)

ProIncluded in $99

A composer where talking comes first: a large mic that becomes the live waveform, the words appearing as you speak, and one tap to switch to typing without losing any of them.

ProA cook with floury hands talks to a recipe assistant, then taps Type to add a detail. Every word said comes along.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/voice-first-composer

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { VoiceFirstComposer } from "@/components/ui/chatcn/pro/voice-first-composer"

<VoiceFirstComposer
  value={heard}
  onValueChange={setHeard}
  interim={partial}
  listening={mic.open}
  onListeningChange={(open) => (open ? mic.start() : mic.stop())}
  level={mic.getLevel}
  onSubmit={({ text, via }) => send(text)}
/>

The mic is one object in two shapes. At rest it is a round ink button; pressed, the circle stretches into a pill that holds the elapsed time, the live waveform and a stop square, so the thing you pressed is the thing that is listening. The words appear above as your recognizer sends them: settled words in ink, the ones still being heard in gray. Type, or a tap on the words, switches to the keyboard and takes everything said so far, the unsettled words too, with the caret at the end; Talk switches back and opens the mic. Send while listening closes the mic and sends what was said. Audio capture and recognition stay in your app: append final words to value, pass the in-flight words as interim and a level getter for the waveform. Text mode is the free PromptInput, with the same Enter, paste and IME behaviour.

Examples

States

ProReady, listening, finishing the transcript, words in, switched to typing, streaming, a blocked mic and disabled.

Props

PropTypeNotes
value, defaultValue, onValueChangestringWhat was said or typed. Your recognizer appends final words here
interimstringWords heard but not settled. Kept when switching to typing
listening, onListeningChangebooleanThe mic is open, and the mic button was pressed
levelnumber | () => numberInput level from 0 to 1 for the waveform
processingbooleanThe last words are settling after the mic closed
errorReactNode | trueReplaces the transcript. true shows the blocked mic message
mode, defaultMode, onModeChange"voice" | "text"Default voice
onSubmit({ text, via }) => voidvia says whether the last words were spoken or typed
status, onStop"idle" | "submitting" | "streaming"Send becomes Stop in the same footprint
tools, attachmentsReactNodeText mode toolbar, and above the words
disabled, labelsEvery string is a label

Keyboard

KeyAction
Space or Enter on the micOpen or close the microphone
EscapeClose the microphone, keeping the words. Stops a streaming reply otherwise
Enter on the wordsSwitch to typing with the caret at the end
Enter, Shift Enter in text modeSend, new line. Never sends while an IME is composing

Accessibility

  • The mic is a toggle button with aria-pressed; its name changes between Start talking and Stop listening.
  • Opening the mic is announced once, politely; the transcript is not announced word by word.
  • A blocked mic is an alert that says how to fix it, and Type stays available.
  • The focus ring is clipped to the same shape as the mic, so it follows the circle and the pill.

Motion

The circle opens into the pill in 280 ms on the kit's ease out by animating only its clip path, which also clips the hit area; the time, waveform and stop square fade in 75 ms later. The mic glyph leaves with a 2 px blur. Reduced motion snaps the shape and keeps the fades, and the waveform rests on its own reduced form.