docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ChatMessageBubble

    One message in a chat conversation.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BaseVisualElement
    ChatMessageBubble
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    Inherited Members
    BaseVisualElement.contextPrefix
    BaseVisualElement.densityOverride
    BaseVisualElement.themeOverride
    BaseVisualElement.langOverride
    BaseVisualElement.layoutDirectionOverride
    BaseVisualElement.preferredTooltipPlacementOverride
    BaseVisualElement.tooltipDelayMsOverride
    BaseVisualElement.GetLayoutDirectionUssClassName(Dir)
    VisualElement.disabledUssClassName
    VisualElement.SetActivePseudoState(bool)
    VisualElement.SetCheckedPseudoState(bool)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    VisualElement.IsMarkedForRepaint()
    VisualElement.ContainsPoint(Vector2)
    VisualElement.Overlaps(Rect)
    VisualElement.DoMeasure(float, VisualElement.MeasureMode, float, VisualElement.MeasureMode)
    VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(string)
    VisualElement.RemoveFromClassList(string)
    VisualElement.ToggleInClassList(string)
    VisualElement.EnableInClassList(string, bool)
    VisualElement.ClassListContains(string)
    VisualElement.FindAncestorUserData()
    VisualElement.SetBinding(BindingId, Binding)
    VisualElement.GetBinding(BindingId)
    VisualElement.TryGetBinding(BindingId, out Binding)
    VisualElement.GetBindingInfos()
    VisualElement.GetBindingInfos(List<BindingInfo>)
    VisualElement.HasBinding(BindingId)
    VisualElement.ClearBinding(BindingId)
    VisualElement.ClearBindings()
    VisualElement.GetHierarchicalDataSourceContext()
    VisualElement.GetDataSourceContext(BindingId)
    VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
    VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
    VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(int, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(int)
    VisualElement.Clear()
    VisualElement.ElementAt(int)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    VisualElement.Sort(Comparison<VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    VisualElement.GetFirstOfType<T>()
    VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    VisualElement.viewDataKey
    VisualElement.userData
    VisualElement.canGrabFocus
    VisualElement.focusController
    VisualElement.disablePlayModeTint
    VisualElement.usageHints
    VisualElement.transform
    VisualElement.scaledPixelsPerPoint
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.hasActivePseudoState
    VisualElement.hasInactivePseudoState
    VisualElement.hasHoverPseudoState
    VisualElement.hasCheckedPseudoState
    VisualElement.hasEnabledPseudoState
    VisualElement.hasDisabledPseudoState
    VisualElement.hasFocusPseudoState
    VisualElement.hasRootPseudoState
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.languageDirection
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.dataSource
    VisualElement.dataSourcePath
    VisualElement.dataSourceType
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.resolvedStyle
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
    CallbackEventHandler.UnregisterAllRemovableCallbacks()
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    CallbackEventHandler.HandleEventBubbleUp(EventBase)
    CallbackEventHandler.HandleEventTrickleDown(EventBase)
    CallbackEventHandler.ExecuteDefaultAction(EventBase)
    CallbackEventHandler.NotifyPropertyChanged(in BindingId)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    [UxmlElement]
    public class ChatMessageBubble : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
    Remarks

    The two roles look deliberately different. A User message is a filled, right-aligned bubble carrying the prompt text and, above it, whatever the message was sent with. A Assistant message has no bubble at all: its content runs flush with the conversation so long answers do not sit inside a box.

    Four containers are exposed as slots. sentWith holds the context chips and file pills the message was sent with, and only shows inside a user bubble. The content container (what Add reaches) holds richer assistant content, for instance a ChatActivityTimeline or a ChatTodoList. footer and actions sit under the message, the latter typically holding a ChatMessageActions row. Every slot collapses to nothing while it is empty, so there is no state to keep in sync.

    trimContent is opt-in on purpose: backends often pad prompt text, but the bubble must never mutate whitespace-sensitive caller content unless it is asked to. Internal newlines are always preserved.

    Examples

    A user message with an action row under it.

    var message = new ChatMessageBubble
    {
        role = ChatMessageRole.User,
        content = "  Make the player jump higher  ",
        trimContent = true
    };
    message.actions.Add(new ChatMessageActions { content = message.content });
    parentElement.Add(message);

    An assistant message carrying an activity timeline under its answer.

    var answer = new ChatMessageBubble
    {
        role = ChatMessageRole.Assistant,
        content = "I raised the jump force to 8."
    };
    answer.Add(new ChatActivityTimeline());
    parentElement.Add(answer);

    In UXML. Children land in the content container.

    <appui:ChatMessageBubble role="User" content="Hello" />
    <appui:ChatMessageBubble role="Assistant" content="Hi there" />

    Constructors

    ChatMessageBubble()

    Default constructor.

    Declaration
    public ChatMessageBubble()

    Fields

    actionsUssClassName

    The styling class of the actions slot.

    Declaration
    public const string actionsUssClassName = "appui-chat-message-bubble__actions"
    Field Value
    Type Description
    string

    bubbleUssClassName

    The styling class of the bubble surface.

    Declaration
    public const string bubbleUssClassName = "appui-chat-message-bubble__bubble"
    Field Value
    Type Description
    string

    containerUssClassName

    The styling class of the content container.

    Declaration
    public const string containerUssClassName = "appui-chat-message-bubble__container"
    Field Value
    Type Description
    string

    contentUssClassName

    The styling class of the message text.

    Declaration
    public const string contentUssClassName = "appui-chat-message-bubble__content"
    Field Value
    Type Description
    string

    footerUssClassName

    The styling class of the footer slot.

    Declaration
    public const string footerUssClassName = "appui-chat-message-bubble__footer"
    Field Value
    Type Description
    string

    roleUssClassName

    The ChatMessageBubble role styling class.

    Declaration
    public const string roleUssClassName = "appui-chat-message-bubble--"
    Field Value
    Type Description
    string

    sentWithUssClassName

    The styling class of the "sent with" row.

    Declaration
    public const string sentWithUssClassName = "appui-chat-message-bubble__sent-with"
    Field Value
    Type Description
    string

    ussClassName

    The ChatMessageBubble main styling class.

    Declaration
    public const string ussClassName = "appui-chat-message-bubble"
    Field Value
    Type Description
    string

    Properties

    actions

    The per-message action row, under everything else.

    Declaration
    public VisualElement actions { get; }
    Property Value
    Type Description
    VisualElement

    content

    The message text.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public string content { get; set; }
    Property Value
    Type Description
    string
    Remarks

    Reading this back returns exactly what was set, not the trimmed rendering, so a caller can hand the same string to a copy action without it having been silently rewritten.

    contentContainer

    Richer message content, for instance an activity timeline or a todo list. This is what Add reaches.

    Declaration
    public override VisualElement contentContainer { get; }
    Property Value
    Type Description
    VisualElement
    Overrides
    VisualElement.contentContainer

    footer

    The slot under the message, before the actions.

    Declaration
    public VisualElement footer { get; }
    Property Value
    Type Description
    VisualElement

    role

    Who authored the message. Assistant by default.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public ChatMessageRole role { get; set; }
    Property Value
    Type Description
    ChatMessageRole

    sentWith

    What the message was sent with: context chips and file pills. Only visible on a user message.

    Declaration
    public VisualElement sentWith { get; }
    Property Value
    Type Description
    VisualElement

    trimContent

    Whether leading and trailing whitespace is trimmed from content before it is displayed. False by default. Internal newlines are always preserved.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public bool trimContent { get; set; }
    Property Value
    Type Description
    bool

    Methods

    GetRoleUssClassName(ChatMessageRole)

    Declaration
    public static string GetRoleUssClassName(ChatMessageRole enumValue)
    Parameters
    Type Name Description
    ChatMessageRole enumValue
    Returns
    Type Description
    string

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    RegisterUpdateCallbackExtensions.RegisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    RegisterUpdateCallbackExtensions.UnregisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    VisualElementExtensions.EnableDynamicTransform(VisualElement, bool)
    VisualElementExtensions.EnablePicking(VisualElement, bool)
    VisualElementExtensions.GetChildren<T>(VisualElement, bool)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement, string)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement, string)
    VisualElementExtensions.GetExclusiveRootElement(VisualElement)
    VisualElementExtensions.GetLastAncestorOfType<T>(VisualElement)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement, string)
    VisualElementExtensions.GetTooltipContent(VisualElement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.HasAncestorOfType<T>(VisualElement, bool)
    VisualElementExtensions.HasAncestorsOfType<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement, string)
    VisualElementExtensions.IsInvisible(VisualElement)
    VisualElementExtensions.IsOnScreen(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, string, T)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, OptionalEnum<PopoverPlacement>)
    VisualElementExtensions.SetTooltipContent(VisualElement, VisualElementExtensions.TooltipContentCallback)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)