MessageInputContext

MessageInputContext is provided by Channel. If you are not familiar with the React Context API, see the React docs.

Best Practices

  • Prefer useMessageInputContext for consistent access and typings.
  • Use context handlers (sendMessage, editMessage) to keep behavior aligned with the SDK.
  • Keep input-related props stable to avoid re-renders while typing.
  • Use toggleAttachmentPicker and related helpers to keep picker state consistent.
  • Respect cooldowns and permissions before allowing sends or uploads.

Basic Usage

Consume MessageInputContext in any child of Channel:

import { useContext } from "react";
import { MessageInputContext } from "stream-chat-react-native";

const { sendMessage, toggleAttachmentPicker } = useContext(MessageInputContext);

Alternatively, use the useMessageInputContext hook.

import { useMessageInputContext } from "stream-chat-react-native";

const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();

Value

additionalTextInputProps

Extra props passed to the underlying TextInput in MessageInput.

Type
object

asyncMessagesLockDistance

Pixels the user must drag upward to lock recording and lift their finger without stopping it.

TypeDefault
Number50

asyncMessagesMinimumPressDuration

Minimum press duration (ms) on the record button to start voice recording.

TypeDefault
Number500

asyncMessagesMultiSendEnabled

When enabled, recordings don’t send immediately. They stack in the composer so users can send multiple voice recordings in one message.

TypeDefault
Booleantrue

asyncMessagesSlideToCancelDistance

Pixels the user must drag toward the leading side to cancel voice recording.

TypeDefault
Number100

audioRecordingEnabled

Enable or disable audio recording.

TypeDefault
Booleanfalse

attachmentPickerBottomSheetHandleHeight

Height of the attachment picker bottom sheet handle.

TypeDefault
Number20

attachmentPickerBottomSheetHeight

Height of the attachment picker bottom sheet when open.

TypeDefault
Number40% of Window Height

attachmentSelectionBarHeight

Height of the attachment selection bar in the attachment picker.

TypeDefault
Number52

compressImageQuality

Image compression quality before upload.

On iOS, values >= 0.8 usually keep quality while reducing size. A value of 0.8 can roughly halve file size vs 1.0.

TypeDefault
number 0 to 1
(1 is best quality)
iOS: 0.8
Android: 1

cooldownEndsAt

The time at which the active cool-down will end.

Type
Date

editMessage

Handles the edit message event on the message input by taking the new message as input and updating the message for the client.

Type
Function

The function takes an object as a parameter with the following properties:

ParameterDescription
localMessageContains the message data that will be shown in the UI immediately
optionsContains options for sending/updating the message

handleAttachButtonPress

Customize behavior when the AttachButton is pressed in the message input.

Type
() => void

hasCameraPicker

Enable the camera picker in MessageInput.

TypeDefault
Booleantrue

hasCommands

Enable commands in MessageInput.

TypeDefault
booleantrue

hasFilePicker

Enable the file picker in MessageInput.

TypeDefault
Booleantrue

hasImagePicker

Enable the image picker in MessageInput.

TypeDefault
Booleantrue

sendMessage

Sends a composed message within MessageInput component to channel. This function is attached to onPress handler of SendButton. The message optimistically gets added to message list UI first, before actually making API call to server. During this intermediate stage, MessageStatus component will display an indicator for "pending" state.

Type
Function

The function takes an object as a parameter with the following properties:

ParameterDescription
localMessageContains the message data that will be shown in the UI immediately
messageContains the data that will be sent to the backend
optionsContains options for sending/updating the message

closeAttachmentPicker

Dismiss the attachment picker, if its already open.

Type
Function

closePollCreationDialog

Function called whenever the close button is pressed on the poll creation modal. Has no effect if PollCreateContent is custom.

Type
function

doFileUploadRequest

inputBoxRef

Ref for TextInput component within MessageInput

openAttachmentPicker

Opens the attachment picker bottom sheet, if its not open.

Type
Function

openPollCreationDialog

Called when the poll creation button is clicked in the attachment picker. Use it to override the default modal UI.

If overridden, a payload is passed with sendMessage from MessageInputContext for use in CreatePoll.

Type
function
ParameterDescription
payload{ sendMessage }

pickAndUploadImageFromNativePicker

Opens the native image picker and uploads the selected image.

Type
() => Promise<void>

pickFile

Opens the native document/file picker and uploads the selected files.

Type
() => Promise<void>

selectedPicker

Value is images (string), when image attachment picker is open else undefined.

Type
'images' | undefined

setInputBoxRef

Setter function for inputBoxRef

Type
(ref) => void

showPollCreationDialog

A boolean signifying whether the poll creation dialog is shown or not. Will always be false if PollCreateContent is custom.

Type
boolean

takeAndUploadImage

Function to click an image using the device camera and upload it.

Type
() => Promise<void>

thread

Can be a LocalMessage or ThreadType. Setting it indicates a thread is open. Both types are interchangeable.

With Thread, this displays the thread. With the standard MessageList, it keeps singleton components in OverlayProvider in sync.

Set thread on all Channel components when a thread is open.

Type
object

toggleAttachmentPicker

Function to toggle attachment picker. By default, this function is attached to onPress handler for AttachButton.

Type
Function

uploadNewFile

Function to upload an attached file in MessageInput. This invokes the Message composer Attachment Manager's uploadFiles method to handle the file upload process.

This handles the abort controller to make sure that the upload can be cancelled if needed.

Type
(file: File) => Promise

Components Props

AttachButton

Renders the attach button next to the input box.

TypeDefault
ComponentTypeAttachButton

AttachmentUploadPreviewList

Renders previews of attached files and images in MessageInput.

TypeDefault
ComponentTypeAttachmentUploadPreviewList

AudioAttachmentUploadPreview

Customize the audio attachment upload preview in MessageInput.

TypeDefault
ComponentTypeAudioAttachmentUploadPreview

AudioRecorder

Custom UI for audio recorder controls in MessageInput.

TypeDefault
ComponentTypeAudioRecorder

AudioRecordingInProgress

Custom UI for an in-progress audio recording in MessageInput (waveform, duration, etc.).

TypeDefault
ComponentTypeAudioRecordingInProgress

AudioRecordingLockIndicator

Custom lock indicator for audio recording in MessageInput.

TypeDefault
ComponentTypeAudioRecordingLockIndicator

AudioRecordingPreview

Custom UI to preview and play an audio recording in MessageInput.

TypeDefault
ComponentTypeAudioRecordingPreview

AudioRecordingWaveform

Custom waveform UI for audio recording in MessageInput.

TypeDefault
ComponentTypeAudioRecordingWaveform

AutoCompleteSuggestionHeader

Renders the autocomplete suggestion header.

TypeDefault
ComponentTypeAutoCompleteSuggestionHeader

AutoCompleteSuggestionItem

Renders an autocomplete suggestion item.

TypeDefault
ComponentTypeAutoCompleteSuggestionItem

AutoCompleteSuggestionList

Renders the autocomplete suggestion list.

TypeDefault
ComponentTypeAutoCompleteSuggestionList

AttachmentPickerBottomSheetHandle

Bottom sheet handle component for the attachment picker.

TypeDefault
ComponentTypeundefined | AttachmentPickerBottomSheetHandle

AttachmentPickerSelectionBar

Renders the attachment picker selection bar (image, file, camera icons).

TypeDefault
ComponentTypeundefined | AttachmentPickerSelectionBar

CameraSelectorIcon

Camera selector icon in the attachment selector bar.

TypeDefault
ComponentTypeundefined | CameraSelectorIcon

CooldownTimer

Renders a countdown timer for message send cooldowns in MessageInput.

TypeDefault
ComponentTypeCooldownTimer

CommandsButton

Renders the button next to the input box that opens the commands list.

TypeDefault
ComponentTypeCommandsButton

CommandInput

Renders the message input in an active command state.

TypeDefault
ComponentTypeCommandInput

CreatePollIcon

Create poll icon in the attachment selector bar.

TypeDefault
ComponentTypeundefined | CreatePollIcon

FileSelectorIcon

File selector icon in the attachment selector bar.

TypeDefault
ComponentTypeundefined | FileSelectorIcon

ImageSelectorIcon

Image selector icon in the attachment selector bar.

TypeDefault
ComponentTypeundefined | ImageSelectorIcon

VideoRecorderSelectorIcon

Video recorder selector icon in the attachment selector bar.

TypeDefault
ComponentTypeundefined | VideoRecorderSelectorIcon

FileAttachmentUploadPreview

Customize the file attachment upload preview in MessageInput.

TypeDefault
ComponentTypeFileAttachmentUploadPreview

ImageAttachmentUploadPreview

Customize the image attachment upload preview in MessageInput.

TypeDefault
ComponentTypeImageAttachmentUploadPreview

VideoAttachmentUploadPreview

Customize the video attachment upload preview in MessageInput.

TypeDefault
ComponentTypeVideoAttachmentUploadPreview

AttachmentUploadProgressIndicator

Renders upload progress for images/files in the message input.

TypeDefault
ComponentTypeAttachmentUploadProgressIndicator

Input

Renders the UI for the enclosed MessageInput. See Customizing Message Input.

Type
ComponentType

InputButtons

Renders action buttons (CommandsButton and AttachButton) on the left side of the MessageInput.

TypeDefault
ComponentTypeInputButtons

InputEditingStateHeader

Renders the header when editing a message in the input.

TypeDefault
ComponentTypeInputEditingStateHeader

InputReplyStateHeader

Renders the reply header in the message input.

TypeDefault
ComponentTypeInputReplyStateHeader

MoreOptionsButton

Renders the MessageInput “more options” button (for AttachButton, CommandsButton, etc.).

TypeDefault
ComponentTypeMoreOptionsButton

SendButton

Renders the send message button inside MessageInput.

TypeDefault
ComponentTypeSendButton

SendMessageDisallowedIndicator

Renders an indicator when the current user can’t send messages.

TypeDefault
ComponentTypeSendMessageDisallowedIndicator

ShowThreadMessageInChannelButton

Renders a checkbox in Thread that sets show_in_channel to true when checked.

TypeDefault
ComponentTypeShowThreadMessageInChannelButton

StartAudioRecordingButton

Custom mic button for audio recording in MessageInput.

TypeDefault
ComponentTypeStartAudioRecordingButton

CreatePollContent

A custom UI component used to render the entire poll creation form. It has access to the CreatePollContext values by default through the useCreatePollContext hook.

TypeDefault
ComponentTypeCreatePollContent