Text Input
Text input component for sending text messages to the bot
The TextInput component provides a user interface for entering and sending textual messages to the bot. It includes both a headless variant for full control and a connected variant that automatically integrates with the Pipecat Client SDK.
import { TextInput, ConversationProvider } from "@pipecat-ai/voice-ui-kit";
<ConversationProvider>
<TextInput placeholder="Ask me anything..." />
</ConversationProvider>Component Variants
TextInput
The TextInput component is the connected variant that automatically integrates with the Pipecat Client SDK. It must be used within a PipecatClientProvider context.
| Prop | Type | Default |
|---|---|---|
debounceTime? | number | 300 |
disabled? | boolean | false |
sendTextOptions? | SendTextOptions | undefined |
noInject? | boolean | false |
noConnectedPlaceholder? | string | "Connect to send" |
onSend? | (message: string) => Promise<void> | void | undefined |
multiline? | boolean | false |
buttonLabel? | React.ReactNode | undefined |
buttonIcon? | React.ReactNode | <SendIcon /> |
buttonProps? | ButtonProps | undefined |
classNames? | { container?: string; input?: string; button?: string; } | undefined |
placeholder? | string | "Type message..." |
size? | "sm" | "md" | "lg" | "xl" | "md" |
SendTextOptions
The sendTextOptions prop accepts an object with the following properties:
| Prop | Type | Default |
|---|---|---|
run_immediately? | boolean | true |
audio_response? | boolean | true |
TextInputComponent
The TextInputComponent is the headless variant that accepts all callbacks and state as props. This allows you to use it with any framework or state management solution.
import { TextInputComponent } from "@pipecat-ai/voice-ui-kit";
function Demo() {
const handleSend = async (message: string) => {
console.log("Sending message:", message);
// Simulate API call
await new Promise(resolve => setTimeout(resolve, 1000));
};
return (
<TextInputComponent
placeholder="Type your message..."
onSend={handleSend}
buttonLabel="Send Message"
/>
);
}
render(<Demo />);| Prop | Type | Default |
|---|---|---|
debounceTime? | number | 300 |
onSend? | (message: string) => Promise<void> | void | undefined |
disabled? | boolean | false |
multiline? | boolean | false |
buttonLabel? | React.ReactNode | undefined |
buttonIcon? | React.ReactNode | <SendIcon /> |
buttonProps? | ButtonProps | undefined |
classNames? | { container?: string; input?: string; button?: string; } | undefined |
placeholder? | string | "Type message..." |
size? | "sm" | "md" | "lg" | "xl" | "md" |
Usage
SendTextOptions
You can customize how the bot handles text messages using the sendTextOptions prop.
import { TextInput, ConversationProvider } from "@pipecat-ai/voice-ui-kit";
<ConversationProvider>
<TextInput
placeholder="Send a text-only message..."
sendTextOptions={{
run_immediately: true,
audio_response: false, // Bot will respond with text only, no TTS
}}
/>
</ConversationProvider>Disable Message Injection
By default, messages sent via TextInput are automatically injected into the conversation store. You can disable this behavior with the noInject prop if you want to handle message injection manually.
import { TextInput, ConversationProvider } from "@pipecat-ai/voice-ui-kit";
<ConversationProvider>
<TextInput
placeholder="Send without auto-injecting..."
noInject={true}
onSend={(message) => {
console.log("Message sent:", message);
// Handle message injection manually if needed
}}
/>
</ConversationProvider>Integration
The TextInput component uses:
usePipecatConnectionStatehook to check connection statususePipecatClienthook to access the Pipecat client instanceuseConversationContexthook to inject messages into the conversation store
It must be used within:
PipecatClientProvidercontext (for client access and connection state)ConversationProvidercontext (for message injection)