Skip to main content

Prompt Input

Input component for sending chat messages with support for attachments, voice input, and auto-resize. Features smart textarea that grows with content and keyboard shortcuts for better UX.

Preview

0 / 500

Installation

Terminalbash

Usage

Reacttsx

Examples

With Attachments and Voice

0 / 500
tsx

Loading State

Try sending a message to see the loading state for 2 seconds.

tsx

Controlled Component

Current value: (empty)

tsx

Props

NameTypeDefaultDescription
onSend
(value: string) => voidCallback when send button is clicked or Enter is pressed
isLoading
booleanfalseWhether the input is in loading state
showAttachment
booleanfalseShow file attachment button
showVoice
booleanfalseShow voice input button
showCounter
booleanfalseShow character/token counter
maxLength
numberMaximum characters allowed
onAttachment
() => voidCallback when attachment button is clicked
onVoice
() => voidCallback when voice button is clicked
isRTL
booleanfalseWhether text direction is RTL
placeholder
stringPlaceholder text
placeholderAr
stringPlaceholder text in Arabic
value
stringControlled value
onChange
(e: React.ChangeEvent<HTMLTextAreaElement>) => voidChange handler for controlled component

Accessibility

Screen Reader

All action buttons include screen reader labels. The textarea has proper ARIA attributes and placeholder text that guides users.

Keyboard Navigation

  • Enter: Send message
  • Shift+Enter: New line
  • Tab: Navigate to action buttons

Auto-resize

The textarea automatically expands as content grows, up to 200px maximum height, ensuring content remains visible without manual resizing.

RTL Considerations

The input automatically adapts to RTL layout. Action buttons move to the left side, and text direction changes. Set isRTL prop for RTL languages.

LTR (English)

RTL (العربية)

Related Components

Chat Message

Display chat messages from users and AI

Thinking Indicator

Loading state for AI responses

Message Actions

Action buttons for chat messages