Skip to content

Commit e6b46e5

Browse files
committed
docs: add info about chat new features #12450
1 parent a084921 commit e6b46e5

File tree

5 files changed

+439
-14
lines changed

5 files changed

+439
-14
lines changed

components/chat/file-uploads-and-media.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ Enable file uploads by setting the `EnableFileUpload` parameter to `true`:
2121
</TelerikChat>
2222
````
2323

24+
## Message Files Layout
25+
26+
The `MessageFilesLayoutMode` parameter controls how file attachments are displayed within chat messages. Choose from three layout options to best fit your application's design:
27+
28+
* `ChatMessageFilesLayoutMode.Vertical` - Files are displayed in a vertical stack (default)
29+
* `ChatMessageFilesLayoutMode.Horizontal` - Files are displayed in a horizontal row
30+
* `ChatMessageFilesLayoutMode.Wrap` - Files wrap to the next line when they exceed the message width
31+
32+
````RAZOR.skip-repl
33+
<TelerikChat Data="@ChatData"
34+
EnableFileUpload="true"
35+
MessageFilesLayoutMode="@ChatMessageFilesLayoutMode.Horizontal">
36+
</TelerikChat>
37+
````
38+
2439
## File Upload Settings
2540

2641
Configure file upload behavior using the `ChatFileSelectSettings` component:

components/chat/messages.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,70 @@ position: 5
1212

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

15+
## Typing Indicator
16+
17+
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.
18+
19+
````Razor
20+
<TelerikButton OnClick="@AddTypingMessage">Show Typing Indicator</TelerikButton>
21+
22+
<TelerikChat Data="@ChatData"
23+
@ref="@ChatRef"
24+
AuthorId="@CurrentUserId"
25+
IsTypingField="@nameof(ChatMessage.IsTyping)"
26+
OnSendMessage="@OnChatSendMessage">
27+
</TelerikChat>
28+
29+
@code {
30+
private TelerikChat<ChatMessage> ChatRef { get; set; }
31+
private List<ChatMessage> ChatData { get; set; } = new();
32+
private string CurrentUserId { get; set; } = "user1";
33+
34+
private void AddTypingMessage()
35+
{
36+
var typingMessage = new ChatMessage
37+
{
38+
Id = Guid.NewGuid().ToString(),
39+
Content = null,
40+
AuthorId = "support",
41+
AuthorName = "Support Agent",
42+
Timestamp = DateTime.Now,
43+
IsTyping = true
44+
};
45+
46+
ChatData.Add(typingMessage);
47+
}
48+
49+
private void OnChatSendMessage(ChatSendMessageEventArgs args)
50+
{
51+
ChatData.RemoveAll(m => m.IsTyping);
52+
53+
var newMessage = new ChatMessage
54+
{
55+
Id = Guid.NewGuid().ToString(),
56+
Content = args.Message,
57+
AuthorId = CurrentUserId,
58+
Timestamp = DateTime.Now
59+
};
60+
61+
ChatData.Add(newMessage);
62+
ChatRef?.Refresh();
63+
}
64+
65+
public class ChatMessage
66+
{
67+
public string Id { get; set; }
68+
public string AuthorId { get; set; }
69+
public string AuthorName { get; set; }
70+
public string Content { get; set; }
71+
public bool IsTyping { get; set; }
72+
public DateTime Timestamp { get; set; }
73+
}
74+
}
75+
````
76+
77+
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.
78+
1579
## Context Menu Message Actions
1680

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

246+
## Author and Receiver Message Settings
247+
248+
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.
249+
250+
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.
251+
252+
````Razor
253+
<TelerikChat Data="@ChatData"
254+
@ref="@ChatRef"
255+
AuthorId="@CurrentUserId"
256+
OnSendMessage="@OnChatSendMessage">
257+
<ChatSettings>
258+
<ChatAuthorMessageSettings EnableMessageCollapse="true"
259+
MessageWidthMode="@MessageWidthMode.Full">
260+
<ChatMessageContextMenuActions>
261+
<ChatMessageContextMenuAction Name="Edit" Text="Edit" Icon="@SvgIcon.Pencil" />
262+
<ChatMessageContextMenuAction Name="Delete" Text="Delete" Icon="@SvgIcon.Trash" />
263+
</ChatMessageContextMenuActions>
264+
<ChatMessageToolbarActions>
265+
<ChatMessageToolbarAction Icon="@SvgIcon.Pin" OnClick="@PinMessage" Text="Pin My Message" />
266+
</ChatMessageToolbarActions>
267+
<ChatFileActions>
268+
<ChatFileAction Name="Download" Text="Download My File" />
269+
</ChatFileActions>
270+
</ChatAuthorMessageSettings>
271+
272+
<ChatReceiverMessageSettings EnableMessageCollapse="false"
273+
MessageWidthMode="@MessageWidthMode.Standard">
274+
<ChatMessageContextMenuActions>
275+
<ChatMessageContextMenuAction Name="Reply" Text="Reply" Icon="@SvgIcon.Undo" />
276+
<ChatMessageContextMenuAction Name="Forward" Text="Forward" Icon="@SvgIcon.Forward" />
277+
</ChatMessageContextMenuActions>
278+
<ChatMessageToolbarActions>
279+
<ChatMessageToolbarAction Icon="@SvgIcon.Heart" OnClick="@ReactToMessage" Text="Like" />
280+
</ChatMessageToolbarActions>
281+
<ChatFileActions>
282+
<ChatFileAction Name="Download" Text="Download Shared File" />
283+
</ChatFileActions>
284+
</ChatReceiverMessageSettings>
285+
</ChatSettings>
286+
</TelerikChat>
287+
288+
@code {
289+
private TelerikChat<ChatMessage> ChatRef { get; set; }
290+
private List<ChatMessage> ChatData { get; set; } = new()
291+
{
292+
new ChatMessage()
293+
{
294+
Id = "1",
295+
AuthorId = "support",
296+
Content = "Hello! How can I assist you today?",
297+
Timestamp = DateTime.Now.AddMinutes(-10)
298+
},
299+
new ChatMessage()
300+
{
301+
Id = "2",
302+
AuthorId = "user1",
303+
Content = "Hi, I have a question about the new features.",
304+
Timestamp = DateTime.Now.AddMinutes(-5)
305+
}
306+
};
307+
private string CurrentUserId { get; set; } = "user1";
308+
309+
private void OnChatSendMessage(ChatSendMessageEventArgs args)
310+
{
311+
var newMessage = new ChatMessage
312+
{
313+
Id = Guid.NewGuid().ToString(),
314+
Content = args.Message,
315+
AuthorId = CurrentUserId,
316+
Timestamp = DateTime.Now
317+
};
318+
319+
ChatData.Add(newMessage);
320+
}
321+
322+
private void PinMessage(ChatMessageActionClickEventArgs args)
323+
{
324+
var message = ChatData.FirstOrDefault(m => m.Id == args.MessageId);
325+
if (message != null)
326+
{
327+
message.IsPinned = true;
328+
ChatRef?.Refresh();
329+
}
330+
}
331+
332+
private void ReactToMessage(ChatMessageActionClickEventArgs args)
333+
{
334+
Console.WriteLine($"Liked message: {args.MessageId}");
335+
}
336+
337+
public class ChatMessage
338+
{
339+
public string Id { get; set; }
340+
public string AuthorId { get; set; }
341+
public string Content { get; set; }
342+
public bool IsPinned { get; set; }
343+
public DateTime Timestamp { get; set; }
344+
}
345+
}
346+
````
347+
348+
Available settings for both `ChatAuthorMessageSettings` and `ChatReceiverMessageSettings`:
349+
350+
* `EnableMessageCollapse` - Enables the collapse functionality for long messages
351+
* `MessageWidthMode` - Controls message width (`Standard` or `Full`)
352+
* `ChatMessageContextMenuActions` - Define context menu actions for right-click interactions
353+
* `ChatMessageToolbarActions` - Define toolbar actions that appear on hover or selection
354+
* `ChatFileActions` - Define actions available for file attachments
355+
356+
If no author or receiver-specific setting is provided, the component falls back to the global Chat settings.
357+
358+
## Send Message Button Customization
359+
360+
Customize the appearance of the send message button using the `ChatSendMessageButtonSettings` component. The `Class` parameter allows you to apply custom CSS classes for styling.
361+
362+
````Razor
363+
<TelerikChat Data="@ChatData"
364+
AuthorId="@CurrentUserId"
365+
OnSendMessage="@OnChatSendMessage">
366+
<ChatSettings>
367+
<ChatSendMessageButtonSettings Class="custom-send-button" />
368+
</ChatSettings>
369+
</TelerikChat>
370+
371+
<style>
372+
.custom-send-button {
373+
background-color: #4CAF50;
374+
color: white;
375+
border-radius: 50%;
376+
padding: 10px;
377+
}
378+
379+
.custom-send-button:hover {
380+
background-color: #45a049;
381+
}
382+
</style>
383+
````
384+
182385
## Message Box Value Persistence
183386

184387
The message box value represents the text that users have typed but haven't sent yet.

components/chat/overview.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,24 @@ The Chat component provides a variety of parameters:
130130

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

148152
## Chat Reference and Methods
149153

components/chat/quick-actions.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,101 @@ The Telerik UI for Blazor Chat component supports quick actions and message sugg
1616

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

19+
## Suggestions Layout Mode
20+
21+
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:
22+
23+
* `ChatSuggestionsLayoutMode.Wrap` - Suggestions wrap to the next line if they exceed the container width (default)
24+
* `ChatSuggestionsLayoutMode.Scroll` - Suggestions are displayed in a single line with horizontal scrolling
25+
* `ChatSuggestionsLayoutMode.ScrollButtons` - Suggestions are displayed in a single line with horizontal scrolling and navigation buttons
26+
27+
````Razor
28+
<TelerikChat Data="@ChatData"
29+
Suggestions="@QuickReplies"
30+
SuggestionsLayoutMode="@ChatSuggestionsLayoutMode.Scroll"
31+
OnSuggestionClick="@HandleSuggestionClick">
32+
</TelerikChat>
33+
34+
@code {
35+
private List<ChatMessage> ChatData { get; set; } = new();
36+
37+
private List<string> QuickReplies = new List<string>
38+
{
39+
"Request project status update",
40+
"Schedule a follow-up meeting",
41+
"Review document",
42+
"Send report",
43+
"Approve changes"
44+
};
45+
46+
private void HandleSuggestionClick(ChatSuggestionClickEventArgs args)
47+
{
48+
// Handle suggestion click
49+
}
50+
51+
public class ChatMessage
52+
{
53+
public string Id { get; set; }
54+
public string AuthorId { get; set; }
55+
public string Content { get; set; }
56+
public DateTime Timestamp { get; set; }
57+
}
58+
}
59+
````
60+
61+
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.
62+
63+
## Suggested Actions Layout Mode
64+
65+
The `SuggestedActionsLayoutMode` parameter controls how suggested actions (quick actions attached to specific messages) are displayed. Similar to `SuggestionsLayoutMode`, it offers three layout options:
66+
67+
* `ChatSuggestedActionsLayoutMode.Wrap` - Suggested actions wrap to the next line (default)
68+
* `ChatSuggestedActionsLayoutMode.Scroll` - Suggested actions are displayed in a single line with horizontal scrolling
69+
* `ChatSuggestedActionsLayoutMode.ScrollButtons` - Suggested actions are displayed in a single line with horizontal scrolling and navigation buttons
70+
71+
````Razor
72+
<TelerikChat Data="@ChatData"
73+
SuggestedActionsLayoutMode="@ChatSuggestedActionsLayoutMode.ScrollButtons"
74+
OnSendMessage="@HandleSendMessage">
75+
</TelerikChat>
76+
77+
@code {
78+
private List<ChatMessage> ChatData { get; set; } = new()
79+
{
80+
new ChatMessage
81+
{
82+
Id = "1",
83+
AuthorId = "bot",
84+
Content = "How would you like to proceed?",
85+
Timestamp = DateTime.Now,
86+
SuggestedActions = new List<string>
87+
{
88+
"Option 1: Quick action",
89+
"Option 2: Detailed review",
90+
"Option 3: Schedule later",
91+
"Option 4: Request more info"
92+
}
93+
}
94+
};
95+
96+
private void HandleSendMessage(ChatSendMessageEventArgs args)
97+
{
98+
// Handle send message
99+
}
100+
101+
public class ChatMessage
102+
{
103+
public string Id { get; set; }
104+
public string AuthorId { get; set; }
105+
public string Content { get; set; }
106+
public DateTime Timestamp { get; set; }
107+
public List<string> SuggestedActions { get; set; }
108+
}
109+
}
110+
````
111+
112+
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.
113+
19114
>caption Basic message suggestions
20115
21116
````razor

0 commit comments

Comments
 (0)