# Chat > A conversation panel with message bubbles, a typing indicator and a message box. Source: https://native.shellui.dev/docs/components/data-display/chat ## Installation ```bash shellui-native add chat ``` **Platforms:** MAUI · Avalonia. Also installs `icon`, `button`. ## Usage ### Basic **MAUI** ```xml ``` **Avalonia** ```xml ``` [Live preview](https://native.shellui.dev/preview/index.html?c=chat-basic) `Chat` is the frame: an optional header, a scrolling list of messages and an optional footer, usually a `ChatInput`. Give it a height. The list follows the newest message, unless the reader has scrolled up. ### Sending and streaming `Submitted` passes the trimmed text and clears the box. Add the user's message, then a reply with `IsStreaming`, which shows three bouncing dots until the text arrives: ```csharp private async void OnSend(object? sender, string text) { Conversation.Messages.Add(new ChatMessage { Role = ChatRole.User, Text = text }); var reply = new ChatMessage { Role = ChatRole.Assistant, Sender = "ShellUI", IsStreaming = true }; Conversation.Messages.Add(reply); reply.Text = await AskAsync(text); reply.IsStreaming = false; } ``` Set `IsLoading` on the `ChatInput` while a reply is on its way: the send button shows a spinner and sending is blocked. ### Messages `Role` places and colours the bubble: `User` on one side, `Assistant` on the other, `System` centred. `AvatarText` shows initials next to the bubble, and `Avatar` takes a view instead. `Actions` is a view under the bubble, for copy or retry buttons. A message's child view goes inside the bubble, under the text. ## MAUI and Avalonia On Avalonia, Enter in the `ChatInput` sends and Shift+Enter starts a new line. On MAUI the send button sends. ## API ### Chat XAML children go to `Messages`. | Property | Type | Default | Description | |---|---|---|---| | `Header` | `View` (MAUI) · `Control?` (Avalonia) | `null` | A view above the messages. | | `Footer` | `View` (MAUI) · `Control?` (Avalonia) | `null` | A view below the messages, usually a `ChatInput`. | | `AutoScroll` | `bool` | `true` | Follows new messages and a message that grows, unless the reader has scrolled up. | | Method | Description | |---|---| | `ScrollToEnd(bool animated = true)` | Shows the newest message. | ### ChatMessage XAML children go to `Body`. | Property | Type | Default | Description | |---|---|---|---| | `Role` | `ChatRole` | `Assistant` | Who the message is from; it places and colours the bubble. One of `Assistant`, `User`, `System`. | | `Text` | `string` | — | The message text. | | `Sender` | `string` | — | The sender's name above the bubble. | | `Timestamp` | `string` | — | Time text shown with the sender's name. | | `IsStreaming` | `bool` | `false` | Shows three bouncing dots after the text while a reply is still arriving. | | `AvatarText` | `string` | — | Initials shown in the avatar circle. | | `Avatar` | `View` (MAUI) · `Control?` (Avalonia) | `null` | Any view for the avatar circle (an `Avatar`, an `Icon`); replaces `AvatarText`. | | `Body` | `View` (MAUI) · `Control?` (Avalonia) | `null` | A view inside the bubble, under the text. | | `Actions` | `View` (MAUI) · `Control?` (Avalonia) | `null` | A view under the bubble, for copy or retry buttons. | ### ChatInput | Property | Type | Default | Description | |---|---|---|---| | `Text` | `string` | — | The text in the box. Two-way bindable. | | `Placeholder` | `string` | `"Send a message..."` | Hint shown while empty. | | `IsLoading` | `bool` | `false` | Shows a spinner in the send button and blocks sending. | | `Actions` | `View` (MAUI) · `Control?` (Avalonia) | `null` | A view before the text, for an attach button for example. | | Event | Arguments | Description | |---|---|---| | `Submitted` | `string` | The message was sent; passes the trimmed text. The box is cleared. | | Method | Description | |---|---| | `Submit()` | Sends the text as the button does; does nothing while loading or when the box is empty. |