Dictation ButtonPRO
A round mic button that breathes with your voice, then transcribes.
Code
2 files · 242 lines of TypeScriptPRO
Dictation Button is part of Pro
Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.
Motion notes
- The mic folds into a stop square with a quarter turn, and the button inverts to solid. The one control you need while recording is the one that changed.
- Two layers react to the level: a hairline ring that tracks it closely and a soft halo that swells further. Both read one smoothed motion value written per frame, so React never re-renders while you speak.
- The elapsed timer remounts for each take, so it always counts from 0:00. “Transcribing…” shimmers beside a spinner and the button ignores presses until it finishes.
- With reduced motion the ring holds still at its resting size, the stop square doesn't rotate, and the spinner pulses instead of turning.
Usage
Example
const [state, setState] = useState<MicState>("idle");
<MicButton
state={state}
level={inputLevel}
onStateChange={async (next) => {
setState(next);
if (next === "transcribing") {
setText(await transcribe(recording));
setState("idle");
}
}}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| state | "idle" | "recording" | "transcribing" | — | Controlled state. Omit it and the button runs its own loop, returning to idle after transcribeMs. |
| onStateChange | (state: MicState) => void | — | Called with the state the user asked for: recording on press, transcribing on stop. |
| level | number | — | Live input level, 0–1, e.g. from an AnalyserNode. Omit it for a simulated voice. |
| transcribeMs | number | 1400 | Uncontrolled only: how long “Transcribing…” shows. |
| showStatus | boolean | true | Show the timer and status label beside the button. |
| className | string | — | Classes for the wrapper. |