OfferLifetime Pro for $99

Voice Input

The microphone button in a composer, which becomes a pill with the last second of your level as bars, an mm:ss timer, Stop to keep and Cancel to throw away. It records on its own, or you drive it from your own audio pipeline.

The decision inside it

Denied is a state, with words

When the browser refuses the microphone it says so and says where to allow it. A mic button that silently does nothing after a refused prompt is the most common voice bug, and it reads as broken rather than blocked.

When to use it

Use Voice Input for dictation in a chat composer. Left alone it asks for the microphone, shows the level and hands you the recording as a Blob on stop. If your realtime voice API already owns the microphone, pass state and level and it only draws.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Layro's Voice Input for this.
Install it: npx shadcn@latest add @layro/voice-input
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/voice-input.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @layro registry with your CLI token: see the Namespaced tab.

Usage

components/composer-voice.tsx
import { VoiceInput } from "@/components/ui/voice-input";

export function ComposerVoice({ transcribe }: { transcribe: (audio: Blob) => void }) {
  return (
    <VoiceInput
      size="sm"
      maxDuration={120}
      onStop={(blob) => blob && transcribe(blob)}
      onCancel={() => console.info("discarded")}
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
stateVoiceStateDrive the state yourself. Leave out and the component records on its own.
levelnumberAudio level 0–1, when you drive the state. Ignored while the built-in microphone runs.
useMicrophonebooleanUse the built-in getUserMedia, analyser and MediaRecorder. Default true when `state` is not passed.
maxDurationnumberStop on its own after this many seconds.
onStart() => voidCalled when recording starts (or, when you drive it, when the mic button is pressed).
onStop(blob: Blob | null, durationMs: number) => voidCalled with the recording and its length. The Blob is null when you drive the state.
onCancel() => voidCalled when the recording is thrown away (Cancel or Escape).
transcriptstringA live partial transcript, shown beside the bars while recording.
size"sm" | "md"sm fits inside a composer row; md stands alone. Default md.
errorMessagestringShown in the error state.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Layro foundations, installed alongside it

layro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Idle
  • Asking permission
  • Recording
  • Processing
  • Denied
  • Error

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Lifetime access

Every component, and everything we ship next.

  • All 232 components, source included
  • Every template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.