Overview
TheChatInput component provides the main user input interface for the chat application. It features an auto-resizing textarea, submit button, reset button, and displays a footer with project information. The component handles keyboard shortcuts (Enter to submit, Shift+Enter for new lines) and automatically focuses on load.
Props
The current value of the input field. Should be controlled by parent component state.
Callback function triggered when the input value changes. Receives the new input value as a string.
Callback function triggered when the user submits the message (via button click or Enter key).
Callback function triggered when the user clicks the reset/home button.
Callback function for info button clicks (defined in interface but not currently used in implementation).
Whether the reset button should be disabled. Typically true when there are no messages.
Whether the chat is currently processing a message. Disables input and buttons during loading.
TypeScript Interface
Usage
Features
Auto-Resize Textarea
- Automatically expands as content grows
- Minimum height: 48px
- Maximum height: 160px
- Smooth transition when resizing
Keyboard Shortcuts
- Enter: Submit message
- Shift + Enter: Insert new line
Visual Feedback
- Glowing shadow effect on focus
- Submit button disabled when input is empty or loading
- Loading state disables all interactions
- Tooltips on action buttons
Action Buttons
-
Submit Button (ArrowRight icon)
- Position: Bottom-right inside textarea
- Disabled when: input empty or loading
-
Reset Button (Home icon)
- Position: Far right inside textarea
- Disabled when:
isResetDisabledis true or loading
Styling
The component uses a dark theme with:- Gray-800 background
- Zinc-700 borders
- Accent color highlights on focus
- White glowing shadow effects
- Responsive padding (sm breakpoint)
Auto-Focus
The component uses theuseFocusOnLoad custom hook to automatically focus the textarea when:
- The component mounts
- The loading state changes
Related Components
ChatHeader
Header with reset functionality
ChatMessage
Displays submitted messages