MessageField

The MessageField component is rendered at the bottom of the chat panel. It includes the text area to write messages, as well as buttons, for example for sending attachments or voice messages.

Props

The MessageField component receives the following props:

NameTypeDescription
conversationConversationThe current conversation
canSendbooleanWhether the messageField has contents that can be sent (within length limits etc.)
canWritebooleanWhether the current user has write access in the current conversation
canDeletebooleanWhether the current user is allowed to delete their own messages in the current conversation
canRecordbooleanWhether the current user can record and send voice messages
canShareFilebooleanWhether the current user is allowed to share a file
canShareLocationbooleanWhether the current user is allowed to share their location
placeholderstringText to be used as placeholder text when the user doesn't have rights to send messages
atTextLimitbooleanWhether the character limit has been reached. Default limit: 10,000 characters.
characterCountnumberThe length of the text that has been entered into the message field
isPlayingAudiobooleanWhether the user is currently playing the audio they have just recorded
audioProgressnumberThe current time in seconds of the audio being played back.
recordingDurationnumberThe length of time in seconds of the audio the user is currently recording
isFocusedbooleanWhether the MessageField has been focused by the current user
isEditingbooleanWhether the MessageField is being used as part of editing a message
isEmojiPickerOpenbooleanWhether the emoji picker has been opened by the current user
enableEmojiPickerbooleanWhether the emoji picker should be shown (False when the UI is shown on mobile devices)
characterCountnumberThe number of text characters in the editor
atTextLimitbooleanWhether the character limit has been reached. Default limit: 10,000 characters.
uploadErrorbooleanWhether there was an error uploading the voice message
uploadErrorMessagestring | nilMessage describing an error that occurred while uploading a voice message
uploadState"pending" | "done" | nilCurrent state of uploading a voice message
recordingState"not_recording" | "recording" | "previewing"State of recording a voice message

Available system components

The following system components are available to the MessageField component:

EmojiPicker

The <EmojiPicker> system component shows emojis that the user can pick from to insert into the message.

Props

This component takes no props.

EmojiSuggestionBar

The <EmojiSuggestionBar> renders a horizontal bar when the user uses the : character to choose an emoji. For example :face to begin to select the 🙂 emoji.

Props

NameTypeDescription
classstringThe class given to the suggestion bar

Usage example

1<EmojiSuggestionBar class="emoji-suggestions" />

MentionSuggestList

The <MentionSuggestionBar> system component renders a list of participants that the user can mention when they enter the @ character in the MessageField. This list is anchored right above the position of the @ in the MessageField.

Props

NameTypeDescription
classstringThe class given to the list

Usage example

1<MentionSuggestList class="mention-suggestions" />

The <ReferencedMessageLink> system component renders a div which, when clicked, will scroll the message that is being replied to into view.

Props

NameTypeDescription
classstringThe class given to the link

Usage example

1<ReferencedMessageLink class="referenced-message-link">
2 <div class="sender-name">{{ messageData.sender.name }}</div>
3
4 <div class="message">
5 <!-- message markup -->
6 </div>
7</ReferencedMessageLink>

Editor

The <Editor> system component renders a text editor.

Props

NameTypeDescription
classstringThe class given to the editor
characterLimitnumberThe maximum number of characters the user is able to send in a single message
placeholderstringThe placeholder text to show the user when the editor is empty
disabledbooleanDisables the editor. The value passed is irrelevant. If this prop is present, the editor is disabled

Usage example

1<Editor class="emoji-suggestions" characterLimit="{{140}}" placeholder="Your message..." />

To disable the message field, set the disabled attribute to any value.

1<Editor class="emoji-suggestions" disabled="yes" />

LocationButton

The <LocationButton> system component renders a button that, when clicked, will attempt to share the user's current location.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<LocationButton class="location-button" ariaLabel="share location" title="Share your location">
2 <Icon type="locationPin" />
3</LocationButton>

AtachmentButton

The <AttachmentButton> system component renders a button that, when clicked, will bring up the file browser for the user to select and share a file.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<AttachmentButton class="attachment-button" ariaLabel="share file" title="Share a file">
2 <Icon type="attach" />
3</AttachmentButton />

EmojiButton

The <EmojiButton> system component renders a button that, when clicked, will show the emoji picker.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<EmojiButton class="emoji-button" ariaLabel="add emoji" title="Add emoji">
2 <Icon type="emoji" />
3</EmojiButton>

VoiceMessageButton

The <VoiceMessageButton> system component renders a button that, when clicked, will start recording the user's microphone.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<VoiceMessageButton class="voice-button" ariaLabel="record a voice message" title="Record a voice message">
2 <Icon type="mic" />
3</VoiceMessageButton>

CloseButton

The <CloseButton> system component renders a button that, when clicked, will close the ReplyBar, stop the voice recording, or both, depending on the current state of the MessageField.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<CloseButton class="close-button" ariaLabel="cancel" title="Cancel">
2 <Icon type="close" />
3</CloseButton>

PlayButton

The <PlayButton> system component renders a button that will play or pause the audio that the user has just recorded.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<PlayButton class="play-button" ariaLabel="play recording" title="Play">
2 <Icon
3 class="play-pause"
4 type="{{ isPlayingAudio | then: 'pause' | else: 'play' }}"
5 alt="{{ isPlayingAudio | then: 'pause audio' | else: 'play audio'}}"
6 />
7</PlayButton>

PlaybackMenu

The <PlaybackMenu> system component renders a menu where the user can select the rate at which the audio is played back.

Props

NameTypeDescription
speedsstringThe supported playback speeds, as a string of comma-separated numbers

Usage example

1<PlaybackMenu speeds="0.5, 0.75, 1.25, 1.5, 1.75, 2" />

Waveform

The <Waveform> system component renders an audio waveform.

Props

NameTypeDescription
classstringThe class given to the waveform container
heightnumberHeight of the waveform in pixels
barHeightnumberHeight of the waveform bars in pixels
barRadiusnumberThe radius that makes bars rounded
barGapnumberWidth of the gap between bars
barWidthnumberWidth of the bars of the waveform
cursorWidthnumberWidth of the playback cursor
cursorColorstringColor of the cursor indicating the playback position
progressColorstringColor of the part of the waveform that has already been played
waveColorstringColor of the part of the waveform that has not yet been played. When progressColor and waveColor are the same, the progress wave is not rendered at all.

Usage example

1<Waveform
2 class="location-button"
3 height="200"
4 barHeight="180"
5 barRadius="2"
6 barGap="2"
7 barWidth="4"
8 cursorWidth="4"
9 cursorColor="#4545ff"
10 progressColor="#a3a3e3"
11 waveColor="5e5e5e"
12/>

SendButton

The <SendButton> system component renders a button that, when clicked, will send a text message or voice message.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<SendButton class="send-button" ariaLabel="send" title="Send message">
2 <Icon type="send" />
3</SendButton>

CancelButton

The <CancelButton> system component renders a button that, when clicked, will cancel editing a message.

Props

NameTypeDescription
classstringThe class given to the button
ariaLabelstringaria-label attribute for the button
titlestringtitle attribute for the button

Usage example

1<CancelButton class="cancel-button-full" title="{{ strings.CANCEL }}">{{ strings.CANCEL }}</CancelButton>

TextForm

The <TextForm> system component renders a form element that enables the sending of messages and files.

Props

NameTypeDescription
classstringThe class given to the form

Usage example

1<TextForm class="cancel-button-full">
2 <!-- message field markup, including Editor -->
3</TextForm>

ActionButton

A button that, when clicked, emits a conversation action event.

Props

NameTypeDescription
classstringThe class given to the button
actionstringName of the action that gets triggered
data-<foo&tg;stringParameters you want to pass along with the action event.

The values of any attributes starting with data- will be passed along

A link that, when clicked, emits a conversation action event.

Props

NameTypeDescription
classstringThe class given to the link
action RequiredstringName of the action that gets triggered
data-<foo>stringParameters you want to pass along with the action event.

The values of any attributes starting with data- will be passed along

Usage example

This example renders an action button that triggers a conversationAction with "requestPayment" as the action, and a transactionId parameter taken from a custom attribute on the conversation.

1<ActionButton class="action-bittp," action="requestPayment" data-transactionId="{{conversation.custom.transactionId}}">
2 Send payment request
3</ActionButton>