Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions components/chat/file-uploads-and-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ Enable file uploads by setting the `EnableFileUpload` parameter to `true`:
</TelerikChat>
````

## Message Files Layout

The `MessageFilesLayoutMode` parameter controls how file attachments are displayed within chat messages. Choose from three layout options to best fit your application's design:

* `ChatMessageFilesLayoutMode.Vertical` - Files are displayed in a vertical stack (default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `ChatMessageFilesLayoutMode.Vertical` - Files are displayed in a vertical stack (default)
* `ChatMessageFilesLayoutMode.Vertical`&mdash;Files are displayed in a vertical stack (default)

* `ChatMessageFilesLayoutMode.Horizontal` - Files are displayed in a horizontal row
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `ChatMessageFilesLayoutMode.Horizontal` - Files are displayed in a horizontal row
* `ChatMessageFilesLayoutMode.Horizontal`&mdash;Files are displayed in a horizontal row

* `ChatMessageFilesLayoutMode.Wrap` - Files wrap to the next line when they exceed the message width
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `ChatMessageFilesLayoutMode.Wrap` - Files wrap to the next line when they exceed the message width
* `ChatMessageFilesLayoutMode.Wrap`&mdash;Files wrap to the next line when they exceed the message width


````RAZOR.skip-repl
<TelerikChat Data="@ChatData"
EnableFileUpload="true"
MessageFilesLayoutMode="@ChatMessageFilesLayoutMode.Horizontal">
</TelerikChat>
````

## File Upload Settings

Configure file upload behavior using the `ChatFileSelectSettings` component:
Expand Down
203 changes: 203 additions & 0 deletions components/chat/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,70 @@ position: 5

The Telerik UI for Blazor Chat component provides comprehensive control over message display, interactions, and styling to create rich conversational experiences.

## Typing Indicator

The Chat component supports displaying a typing indicator to show when another user is composing a message. Set the `IsTypingField` parameter to specify which field in your data model indicates typing status, and set that field to `true` on a message to display the typing indicator instead of message content.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Chat component supports displaying a typing indicator to show when another user is composing a message. Set the `IsTypingField` parameter to specify which field in your data model indicates typing status, and set that field to `true` on a message to display the typing indicator instead of message content.
The Chat component supports displaying a typing indicator to show when another user is composing a message. First, set the `IsTypingField` parameter to specify which field in your data model indicates typing status. Next, set that field to `true` on a message to display the typing indicator instead of the message content.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, create a numbered list of steps from the last two sentences.


````Razor
<TelerikButton OnClick="@AddTypingMessage">Show Typing Indicator</TelerikButton>

<TelerikChat Data="@ChatData"
@ref="@ChatRef"
AuthorId="@CurrentUserId"
IsTypingField="@nameof(ChatMessage.IsTyping)"
OnSendMessage="@OnChatSendMessage">
</TelerikChat>

@code {
private TelerikChat<ChatMessage> ChatRef { get; set; }
private List<ChatMessage> ChatData { get; set; } = new();
private string CurrentUserId { get; set; } = "user1";

private void AddTypingMessage()
{
var typingMessage = new ChatMessage
{
Id = Guid.NewGuid().ToString(),
Content = null,
AuthorId = "support",
AuthorName = "Support Agent",
Timestamp = DateTime.Now,
IsTyping = true
};

ChatData.Add(typingMessage);
}

private void OnChatSendMessage(ChatSendMessageEventArgs args)
{
ChatData.RemoveAll(m => m.IsTyping);

var newMessage = new ChatMessage
{
Id = Guid.NewGuid().ToString(),
Content = args.Message,
AuthorId = CurrentUserId,
Timestamp = DateTime.Now
};

ChatData.Add(newMessage);
ChatRef?.Refresh();
}

public class ChatMessage
{
public string Id { get; set; }
public string AuthorId { get; set; }
public string AuthorName { get; set; }
public string Content { get; set; }
public bool IsTyping { get; set; }
public DateTime Timestamp { get; set; }
}
}
````

When a message has `IsTyping` set to `true`, the Chat will display an animated typing indicator (typically three dots) instead of the message content. This provides visual feedback that enhances the conversational experience, especially in real-time chat scenarios.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph should ideally be way above, at the beginning of the section.


## Context Menu Message Actions

Configure context menu actions that appear when users right-click on messages. These actions provide quick access to common message operations.
Expand Down Expand Up @@ -179,6 +243,145 @@ Control the width behavior of chat messages using the `MessageWidthMode` paramet
* `MessageWidthMode.Standard` - Messages take up a portion of the available space for better readability (default behavior)
* `MessageWidthMode.Full` - Messages span the full width of the chat container

## Author and Receiver Message Settings

The Chat component allows you to configure settings specifically for author messages (sent by the current user) and receiver messages (received from other users) using `ChatAuthorMessageSettings` and `ChatReceiverMessageSettings` components. These settings take precedence over global Chat settings, enabling different configurations for sent and received messages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Lets" is preferable to "allows to" because "allows" carries the nuance of permission, while "lets" leans toward a capability or enablement.


Use these settings to customize message behavior, appearance, and available actions based on whether the message was sent or received. For example, you might want different context menu actions, toolbar actions, or file actions for your own messages versus messages from others.

````Razor
<TelerikChat Data="@ChatData"
@ref="@ChatRef"
AuthorId="@CurrentUserId"
OnSendMessage="@OnChatSendMessage">
<ChatSettings>
<ChatAuthorMessageSettings EnableMessageCollapse="true"
MessageWidthMode="@MessageWidthMode.Full">
<ChatMessageContextMenuActions>
<ChatMessageContextMenuAction Name="Edit" Text="Edit" Icon="@SvgIcon.Pencil" />
<ChatMessageContextMenuAction Name="Delete" Text="Delete" Icon="@SvgIcon.Trash" />
</ChatMessageContextMenuActions>
<ChatMessageToolbarActions>
<ChatMessageToolbarAction Icon="@SvgIcon.Pin" OnClick="@PinMessage" Text="Pin My Message" />
</ChatMessageToolbarActions>
<ChatFileActions>
<ChatFileAction Name="Download" Text="Download My File" />
</ChatFileActions>
</ChatAuthorMessageSettings>

<ChatReceiverMessageSettings EnableMessageCollapse="false"
MessageWidthMode="@MessageWidthMode.Standard">
<ChatMessageContextMenuActions>
<ChatMessageContextMenuAction Name="Reply" Text="Reply" Icon="@SvgIcon.Undo" />
<ChatMessageContextMenuAction Name="Forward" Text="Forward" Icon="@SvgIcon.Forward" />
</ChatMessageContextMenuActions>
<ChatMessageToolbarActions>
<ChatMessageToolbarAction Icon="@SvgIcon.Heart" OnClick="@ReactToMessage" Text="Like" />
</ChatMessageToolbarActions>
<ChatFileActions>
<ChatFileAction Name="Download" Text="Download Shared File" />
</ChatFileActions>
</ChatReceiverMessageSettings>
</ChatSettings>
</TelerikChat>

@code {
private TelerikChat<ChatMessage> ChatRef { get; set; }
private List<ChatMessage> ChatData { get; set; } = new()
{
new ChatMessage()
{
Id = "1",
AuthorId = "support",
Content = "Hello! How can I assist you today?",
Timestamp = DateTime.Now.AddMinutes(-10)
},
new ChatMessage()
{
Id = "2",
AuthorId = "user1",
Content = "Hi, I have a question about the new features.",
Timestamp = DateTime.Now.AddMinutes(-5)
}
};
private string CurrentUserId { get; set; } = "user1";

private void OnChatSendMessage(ChatSendMessageEventArgs args)
{
var newMessage = new ChatMessage
{
Id = Guid.NewGuid().ToString(),
Content = args.Message,
AuthorId = CurrentUserId,
Timestamp = DateTime.Now
};

ChatData.Add(newMessage);
}

private void PinMessage(ChatMessageActionClickEventArgs args)
{
var message = ChatData.FirstOrDefault(m => m.Id == args.MessageId);
if (message != null)
{
message.IsPinned = true;
ChatRef?.Refresh();
}
}

private void ReactToMessage(ChatMessageActionClickEventArgs args)
{
Console.WriteLine($"Liked message: {args.MessageId}");
}

public class ChatMessage
{
public string Id { get; set; }
public string AuthorId { get; set; }
public string Content { get; set; }
public bool IsPinned { get; set; }
public DateTime Timestamp { get; set; }
}
}
````

Available settings for both `ChatAuthorMessageSettings` and `ChatReceiverMessageSettings`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These non-sentence fragments are not exactly ideal. Consider going with something like "ChatAuthorMessageSettings and Chat... provide the following settings:"


* `EnableMessageCollapse` - Enables the collapse functionality for long messages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch the hyphens to mdashes across the list.

* `MessageWidthMode` - Controls message width (`Standard` or `Full`)
* `ChatMessageContextMenuActions` - Define context menu actions for right-click interactions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, all bullets should follow a unified structure. If the previous were "enables" and "controls", the remaining should be "defines".

* `ChatMessageToolbarActions` - Define toolbar actions that appear on hover or selection
* `ChatFileActions` - Define actions available for file attachments

If no author or receiver-specific setting is provided, the component falls back to the global Chat settings.

## Send Message Button Customization

Customize the appearance of the send message button using the `ChatSendMessageButtonSettings` component. The `Class` parameter allows you to apply custom CSS classes for styling.

````Razor
<TelerikChat Data="@ChatData"
AuthorId="@CurrentUserId"
OnSendMessage="@OnChatSendMessage">
<ChatSettings>
<ChatSendMessageButtonSettings Class="custom-send-button" />
</ChatSettings>
</TelerikChat>

<style>
.custom-send-button {
background-color: #4CAF50;
color: white;
border-radius: 50%;
padding: 10px;
}

.custom-send-button:hover {
background-color: #45a049;
}
</style>
````

## Message Box Value Persistence

The message box value represents the text that users have typed but haven't sent yet.
Expand Down
18 changes: 11 additions & 7 deletions components/chat/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,24 @@ The Chat component provides a variety of parameters:

| Parameter | Type and Default&nbsp;Value | Description |
| --- | --- | --- |
| `Data` | `IEnumerable<TItem>` | The data source for chat messages. |
| `AttachmentsField` | `string` <br /> (`"Attachments"`) | The name of the field containing message file attachments. |
| `AuthorId` | `string` | The ID of the current user sending messages. |
| `TextField` | `string` <br /> (`"Text"`) | The name of the field containing the message content. |
| `AuthorIdField` | `string` <br /> (`"AuthorId"`) | The name of the field containing the author identifier. |
| `TimestampField` | `string` <br /> (`"Timestamp"`) | The name of the field containing the message timestamp. |
| `AuthorNameField` | `string` <br /> (`"AuthorName"`) | The name of the field containing the author display name. |
| `AuthorImageUrlField` | `string` <br /> (`"AuthorImageUrl"`) | The name of the field containing the author's avatar image URL. |
| `AttachmentsField` | `string` <br /> (`"Attachments"`) | The name of the field containing message file attachments. |
| `Height` | `string` | The height of the chat component in CSS units. |
| `Width` | `string` | The width of the chat component in CSS units. |
| `AuthorNameField` | `string` <br /> (`"AuthorName"`) | The name of the field containing the author display name. |
| `Data` | `IEnumerable<TItem>` | The data source for chat messages. |
| `EnableFileUpload` | `bool` <br /> (`false`) | Enables file upload functionality in the chat input. |
| `EnableSpeechToText` | `bool` <br /> (`true`) | Enables speech-to-text functionality with microphone input. |
| `Height` | `string` | The height of the chat component in CSS units. |
| `IsTypingField` | `string` | The name of the field that indicates whether a message represents a typing indicator. |
| `MessageFilesLayoutMode` | `ChatMessageFilesLayoutMode` enum <br /> (`Vertical`) | Controls how file attachments are displayed (Vertical, Horizontal, or Wrap). |
| `MessageWidthMode` | `MessageWidthMode` enum <br /> (`Standard`) | Controls the width behavior of messages (Standard or Full). |
| `SuggestedActionsLayoutMode` | `ChatSuggestedActionsLayoutMode` enum <br /> (`Wrap`) | Controls how suggested actions are displayed (Wrap, Scroll, or ScrollButtons). |
| `Suggestions` | `IEnumerable<string>` | Collection of quick reply suggestions. |
| `SuggestionsLayoutMode` | `ChatSuggestionsLayoutMode` enum <br /> (`Wrap`) | Controls how message suggestions are displayed (Wrap, Scroll, or ScrollButtons). |
| `TextField` | `string` <br /> (`"Text"`) | The name of the field containing the message content. |
| `TimestampField` | `string` <br /> (`"Timestamp"`) | The name of the field containing the message timestamp. |
| `Width` | `string` | The width of the chat component in CSS units. |

## Chat Reference and Methods

Expand Down
95 changes: 95 additions & 0 deletions components/chat/quick-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,101 @@ The Telerik UI for Blazor Chat component supports quick actions and message sugg

Message suggestions provide users with quick reply options that appear below the message input area.

## Suggestions Layout Mode

The `SuggestionsLayoutMode` parameter controls how suggestions are displayed in the chat interface. Choose from three layout options to optimize the presentation based on the number and length of your suggestions:

* `ChatSuggestionsLayoutMode.Wrap` - Suggestions wrap to the next line if they exceed the container width (default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to mdashes.

* `ChatSuggestionsLayoutMode.Scroll` - Suggestions are displayed in a single line with horizontal scrolling
* `ChatSuggestionsLayoutMode.ScrollButtons` - Suggestions are displayed in a single line with horizontal scrolling and navigation buttons

````Razor
<TelerikChat Data="@ChatData"
Suggestions="@QuickReplies"
SuggestionsLayoutMode="@ChatSuggestionsLayoutMode.Scroll"
OnSuggestionClick="@HandleSuggestionClick">
</TelerikChat>

@code {
private List<ChatMessage> ChatData { get; set; } = new();

private List<string> QuickReplies = new List<string>
{
"Request project status update",
"Schedule a follow-up meeting",
"Review document",
"Send report",
"Approve changes"
};

private void HandleSuggestionClick(ChatSuggestionClickEventArgs args)
{
// Handle suggestion click
}

public class ChatMessage
{
public string Id { get; set; }
public string AuthorId { get; set; }
public string Content { get; set; }
public DateTime Timestamp { get; set; }
}
}
````

Use `Scroll` or `ScrollButtons` mode when you have many suggestions or longer text that won't fit comfortably in the available width. The `ScrollButtons` mode is particularly helpful for users who prefer button navigation over scrolling gestures.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, these seem more appropriate toward the start of the section.


## Suggested Actions Layout Mode

The `SuggestedActionsLayoutMode` parameter controls how suggested actions (quick actions attached to specific messages) are displayed. Similar to `SuggestionsLayoutMode`, it offers three layout options:

* `ChatSuggestedActionsLayoutMode.Wrap` - Suggested actions wrap to the next line (default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to mdashes :)

* `ChatSuggestedActionsLayoutMode.Scroll` - Suggested actions are displayed in a single line with horizontal scrolling
* `ChatSuggestedActionsLayoutMode.ScrollButtons` - Suggested actions are displayed in a single line with horizontal scrolling and navigation buttons

````Razor
<TelerikChat Data="@ChatData"
SuggestedActionsLayoutMode="@ChatSuggestedActionsLayoutMode.ScrollButtons"
OnSendMessage="@HandleSendMessage">
</TelerikChat>

@code {
private List<ChatMessage> ChatData { get; set; } = new()
{
new ChatMessage
{
Id = "1",
AuthorId = "bot",
Content = "How would you like to proceed?",
Timestamp = DateTime.Now,
SuggestedActions = new List<string>
{
"Option 1: Quick action",
"Option 2: Detailed review",
"Option 3: Schedule later",
"Option 4: Request more info"
}
}
};

private void HandleSendMessage(ChatSendMessageEventArgs args)
{
// Handle send message
}

public class ChatMessage
{
public string Id { get; set; }
public string AuthorId { get; set; }
public string Content { get; set; }
public DateTime Timestamp { get; set; }
public List<string> SuggestedActions { get; set; }
}
}
````

Suggested actions are contextual quick replies that appear below specific messages, helping guide users through conversations or workflows. The layout mode ensures they are displayed effectively regardless of their number or length.

>caption Basic message suggestions

````razor
Expand Down
Loading