Class ThreadComposer
ThreadComposer UI element. Provides a text input area with submit and attach actions.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class ThreadComposer : ExVisualElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder
Constructors
ThreadComposer()
Default constructor.
Declaration
public ThreadComposer()
Fields
actionbarUssClassName
The ThreadComposer actionbar styling class.
Declaration
public const string actionbarUssClassName = "appui-thread-composer__actionbar"
Field Value
| Type | Description |
|---|---|
| string |
attachBtnUssClassName
The ThreadComposer attach button styling class.
Declaration
public const string attachBtnUssClassName = "appui-thread-composer__attach-btn"
Field Value
| Type | Description |
|---|---|
| string |
attachmentsScrollUssClassName
The ThreadComposer attachments scroll view styling class.
Declaration
public const string attachmentsScrollUssClassName = "appui-thread-composer__attachments-scroll"
Field Value
| Type | Description |
|---|---|
| string |
attachmentsUssClassName
The ThreadComposer attachments styling class.
Declaration
public const string attachmentsUssClassName = "appui-thread-composer__attachments"
Field Value
| Type | Description |
|---|---|
| string |
avatarContainerUssClassName
The ThreadComposer avatar styling class.
Declaration
public const string avatarContainerUssClassName = "appui-thread-composer__avatar-container"
Field Value
| Type | Description |
|---|---|
| string |
avatarLabelUssClassName
The ThreadComposer avatar label styling class.
Declaration
public const string avatarLabelUssClassName = "appui-thread-composer__avatar-initials"
Field Value
| Type | Description |
|---|---|
| string |
avatarUssClassName
The ThreadComposer avatar styling class.
Declaration
public const string avatarUssClassName = "appui-thread-composer__avatar"
Field Value
| Type | Description |
|---|---|
| string |
cancelBtnUssClassName
The ThreadComposer cancel button styling class.
Declaration
public const string cancelBtnUssClassName = "appui-thread-composer__cancel-btn"
Field Value
| Type | Description |
|---|---|
| string |
counterCurrentUssClassName
The ThreadComposer character counter "current count" styling class.
Declaration
public const string counterCurrentUssClassName = "appui-thread-composer__counter-current"
Field Value
| Type | Description |
|---|---|
| string |
counterMaxUssClassName
The ThreadComposer character counter "max count" styling class.
Declaration
public const string counterMaxUssClassName = "appui-thread-composer__counter-max"
Field Value
| Type | Description |
|---|---|
| string |
counterSeparatorUssClassName
The ThreadComposer character counter separator styling class.
Declaration
public const string counterSeparatorUssClassName = "appui-thread-composer__counter-separator"
Field Value
| Type | Description |
|---|---|
| string |
counterUssClassName
The ThreadComposer character counter styling class.
Declaration
public const string counterUssClassName = "appui-thread-composer__counter"
Field Value
| Type | Description |
|---|---|
| string |
defaultMaxTextLength
The default maximum text length for the composer.
Declaration
public const int defaultMaxTextLength = 10000
Field Value
| Type | Description |
|---|---|
| int |
dropzoneUssClassName
The ThreadComposer dropzone styling class.
Declaration
public const string dropzoneUssClassName = "appui-thread-composer__dropzone"
Field Value
| Type | Description |
|---|---|
| string |
editingUssClassName
The ThreadComposer editing modifier styling class.
Declaration
public const string editingUssClassName = "appui-thread-composer--editing"
Field Value
| Type | Description |
|---|---|
| string |
emptyUssClassName
The ThreadComposer empty state styling class, which is applied when the text area has no content to switch the toolbar to an inline layout.
Declaration
public const string emptyUssClassName = "appui-thread-composer--empty"
Field Value
| Type | Description |
|---|---|
| string |
forceToolbarUssClassName
The ThreadComposer force toolbar styling class.
Declaration
public const string forceToolbarUssClassName = "appui-thread-composer--force-toolbar"
Field Value
| Type | Description |
|---|---|
| string |
inputBoxUssClassName
The ThreadComposer input box styling class.
Declaration
public const string inputBoxUssClassName = "appui-thread-composer__input-box"
Field Value
| Type | Description |
|---|---|
| string |
saveBtnUssClassName
The ThreadComposer save button styling class.
Declaration
public const string saveBtnUssClassName = "appui-thread-composer__save-btn"
Field Value
| Type | Description |
|---|---|
| string |
sendingProgressUssClassName
The ThreadComposer sending progress indicator styling class,
Declaration
public const string sendingProgressUssClassName = "appui-thread-composer__sending-progress"
Field Value
| Type | Description |
|---|---|
| string |
sendingUssClassName
The ThreadComposer sending state styling class, which can be used to disable input and show a loading state when a message is being submitted.
Declaration
public const string sendingUssClassName = "appui-thread-composer--sending"
Field Value
| Type | Description |
|---|---|
| string |
showAvatarUssClassName
The ThreadComposer show avatar modifier styling class,
which is applied when the showAvatar property is set to true
Declaration
public const string showAvatarUssClassName = "appui-thread-composer--with-avatar"
Field Value
| Type | Description |
|---|---|
| string |
submitBtnUssClassName
The ThreadComposer submit button styling class.
Declaration
public const string submitBtnUssClassName = "appui-thread-composer__submit-btn"
Field Value
| Type | Description |
|---|---|
| string |
textAreaContainerUssClassName
The ThreadComposer text area container styling class.
Declaration
public const string textAreaContainerUssClassName = "appui-thread-composer__textarea-container"
Field Value
| Type | Description |
|---|---|
| string |
textareaUssClassName
The ThreadComposer textarea styling class.
Declaration
public const string textareaUssClassName = "appui-thread-composer__textarea"
Field Value
| Type | Description |
|---|---|
| string |
toolbarContainerUssClassName
The ThreadComposer toolbar container styling class.
Declaration
public const string toolbarContainerUssClassName = "appui-thread-composer__toolbar-container"
Field Value
| Type | Description |
|---|---|
| string |
toolbarUssClassName
The ThreadComposer toolbar styling class.
Declaration
public const string toolbarUssClassName = "appui-thread-composer__toolbar"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The ThreadComposer main styling class.
Declaration
public const string ussClassName = "appui-thread-composer"
Field Value
| Type | Description |
|---|---|
| string |
Properties
alwaysShowToolbar
Whether to always show the toolbar even when the text area is empty.
When false, the toolbar is only shown when there is text in the text area.
Declaration
public bool alwaysShowToolbar { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
attachments
The attachments container of the ThreadComposer, which can be used to display file attachments or previews related to the message being composed.
Declaration
public VisualElement attachments { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
avatar
The Avatar element of the ThreadComposer, which can be used to display the user's avatar next to the composer.
Declaration
public Avatar avatar { get; }
Property Value
| Type | Description |
|---|---|
| Avatar |
contentContainer
The content container of the ThreadComposer.
Declaration
public override VisualElement contentContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
Overrides
dropZone
The DropZone element of the ThreadComposer, which can be used to accept drag and drop operations over the composer.
Declaration
public DropZone dropZone { get; }
Property Value
| Type | Description |
|---|---|
| DropZone |
Remarks
The DropZone is positioned absolutely to overlay the entire input area.
Configure drag acceptance and handle drops using the controller directly,
e.g. composer.dropZone.controller.acceptDrag = ....
encodedValue
Get the final encoded value of the text area, with any mentions encoded using the mention provider.
Declaration
public string encodedValue { get; }
Property Value
| Type | Description |
|---|---|
| string |
isEditing
Whether the composer is in editing mode.
When true, the submit icon-button is hidden and replaced with Cancel and Save buttons.
Declaration
public bool isEditing { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
maxTextLength
The maximum number of characters allowed in the text area.
Drives the underlying maxLength and the visible character counter
(current / max) shown in the toolbar.
Declaration
public int maxTextLength { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
placeholder
The placeholder text for the text area.
Declaration
public string placeholder { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
sending
The sending state of the composer, which can be used to disable input and show a loading state when a message is being submitted.
Declaration
public bool sending { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
showAvatar
Whether to show the avatar next to the composer.
When true, the avatar element is visible and can be set via the avatar property.
Declaration
public bool showAvatar { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
textArea
The TextArea element of the ThreadComposer, which is the main input area for the message content.
Declaration
public TextArea textArea { get; }
Property Value
| Type | Description |
|---|---|
| TextArea |
toolbar
The toolbar element of the ThreadComposer, which contains the attach actions.
Declaration
public VisualElement toolbar { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
value
The current text value.
Declaration
public string value { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
ClearMentionsCache()
Clears the mentions cache. This can be used to reset the mapping between mention display names and their encoded values,
Declaration
public void ClearMentionsCache()
Events
attachClicked
Event invoked when the attach button is clicked.
Declaration
public event Action attachClicked
Event Type
| Type | Description |
|---|---|
| Action |
cancelClicked
Event invoked when the cancel button is clicked in editing mode.
Declaration
public event Action cancelClicked
Event Type
| Type | Description |
|---|---|
| Action |
pasted
Event invoked when a paste command is detected in the text area.
Declaration
public event Action<KeyDownEvent> pasted
Event Type
| Type | Description |
|---|---|
| Action<KeyDownEvent> |
Remarks
The consumer receives the KeyDownEvent and can call StopPropagation() to prevent the default text paste behavior if they want to handle it fully (e.g., pasting an image as an attachment). If propagation is not stopped, the default text paste still occurs.
saveClicked
Event invoked when the save button is clicked in editing mode.
Declaration
public event Action saveClicked
Event Type
| Type | Description |
|---|---|
| Action |
submitClicked
Event invoked when a message is submitted.
Declaration
public event Action<string> submitClicked
Event Type
| Type | Description |
|---|---|
| Action<string> |