Documentation
Components
ChatInput

ChatInput Component

The ChatInput component provides a text input interface for users to compose and send messages.

Import

import { ChatInput } from 'aichatkit'

Usage

Basic Example

basic-chat-input.tsx
import { ChatInput } from 'aichatkit'
 
function BasicChatInput() {
  const handleSend = (message: string) => {
    console.log('Sending message:', message)
  }
 
  return (
    <ChatInput 
      onSend={handleSend}
      placeholder="Type your message..."
    />
  )
}

With File Upload

file-upload-input.tsx
<ChatInput 
  onSend={handleSend}
  onFileUpload={handleFileUpload}
  enableFileUpload={true}
  acceptedFileTypes={['image/*', '.pdf']}
  maxFileSize={10 * 1024 * 1024} // 10MB
/>

API Reference

Props

PropTypeDefaultDescription
onSend(message: string) => void-Callback when message is sent
onFileUpload(files: File[]) => void-Callback when files are uploaded
placeholderstring'Type a message...'Input placeholder text
disabledbooleanfalseWhether input is disabled
enableFileUploadbooleanfalseEnable file upload functionality
acceptedFileTypesstring[]['*']Accepted file types
maxFileSizenumber10485760Maximum file size in bytes
maxLengthnumber2000Maximum message length

The ChatInput component supports keyboard shortcuts like Ctrl+Enter for sending messages.