- Implementation
- PromptBar Props
Common Examples
To use thePromptBar, pass controlled value and onChange. The Send button follows three states:At rest the action would have nothing to do, and a permanently-disabled arrow reads as decoration rather than an affordance — so the resting bar is the editor alone, plus the mic if you wired
onStartVoice. Once the editor is focused the send action appears disabled, so its enabled/disabled state can show what makes a draft sendable. It also stays disabled if onSend is unwired, and sending is allowed when the draft has trimmed text unless you override canSend.maxRows (default 8), then it scrolls.Stop
WhileisSending is true, sending is withheld. Wire onStop to surface Stop instead of Send.Voice
PromptBar supports two distinct, mutually exclusive voice flows. A host uses one or the other, never both.Dictation (speak → transcribe → insert)
The kit does not record or transcribe. WireonStartVoice to show a mic. Drive voiceState ("idle", "listening", "transcribing") from the host. Pass audioLevel (0–1) while listening and transcript while transcribing. Wire onAcceptVoice and onCancelVoice to show those listening-row controls.Live conversation
For a two-way spoken conversation, setisVoiceModeActive. The bar collapses to a single control that returns the user to typing — the editor, mic, and send are all withheld, because one input mode is active at a time. The input surface goes with them: with no editor to frame, the exit control sits bare on the page rather than inside the bar’s usual bordered, elevated pill. The spoken exchange renders as chat messages above, and the conversation’s own controls (mute, stop, collapse) live in the floating VoiceModeFab, not in the bar.isVoiceModeActive and onExitVoiceMode are a required pair — the type will not let you set the flag without the handler. Collapsing the bar withholds the editor, mic and send, so a missing handler would leave the user with no route back to typing. The host ends the conversation and clears the flag.If a host sets both
isVoiceModeActive and a dictation voiceState, voice
mode wins. That combination is a misconfiguration, but collapsing is the
safer render: a listening row would offer an accept control that writes
into an editor the user cannot see.Disclaimer
Pass a plain-stringdisclaimer to show fine print under the bar. Omit it to hide the line. Rich-text and link support are not ported.Disabled
disabled disables the editor, send, and mic.Built-in action labels (sendLabel, stopLabel, startVoiceLabel, and the voice-row labels) default to English. Override them for localized copy.Accessibility
placeholderis the editor’s accessible name.- While listening,
listeningLabelis announced through a polite live region because the level meter is decorative. - While transcribing,
transcribingLabelnames the row untiltranscriptarrives. - Send, Stop, mic, accept, and cancel use the corresponding label props as accessible names.