Import
Usage
Props
Callback when message is sent (Enter key or Send button). For text messages,
data.text contains the message. For voice recordings, data.media contains the audio as base64-encoded WAV format.Attachment menu options. When provided, displays a Plus icon button that opens a Menu component with these options.
Callback when an attachment menu item is clicked. Receives the option
id.Shows loading animation (Lottie), disables input, and changes background to soft gray.
Input placeholder text.
Disables the input and send button.
Custom CSS properties for the container.
Accepts all standard HTML input attributes via
ComponentPropsWithoutRef<"input"> (except value and onChange which are managed internally).Voice Recording Features
- Microphone button: Appears when input is empty, click to start recording
- Waveform visualization: Real-time audio visualization using Canvas API during recording
- Recording controls:
- Trash icon: Cancel and discard recording
- Send icon: Complete and send recording
- Audio format: Automatically converted to base64-encoded WAV format
- MediaRecorder API: Uses browser’s MediaRecorder for audio capture
UI Behavior
- Dynamic button: Shows Send icon when text is present or recording, Mic icon when empty
- Focus styling: Blue border appears on focus (
2pxneutral medium color) - Rounded design: 100px border radius for pill-shaped appearance
- 48px height: Fixed height for consistent layout
Examples
Text Messaging Only
With Attachment Menu
With Voice Recording Handler
With Loading State
Browser Permissions
Voice recording requires microphone access. The component handles permission requests automatically vianavigator.mediaDevices.getUserMedia(). If the user denies permission, recording will fail silently.