ClassTelerikChat<TItem>
A component that enables you to build conversational UIs with messages, suggestions, attachments, and actions. Supports templating (messages, bubbles, header, status), speech-to-text, file upload, message width/layout, context menus and toolbar actions, quick replies, and send/download events.
Definition
Namespace:Telerik.Blazor.Components
Assembly:Telerik.Blazor.dll
Type Parameters:
TItem
Syntax:
public class TelerikChat<TItem> : BaseComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Inheritance: objectComponentBaseBaseComponentTelerikChat<TItem>
Implements:
Inherited Members
Constructors
TelerikChat()
Declaration
public TelerikChat()
Properties
AuthorId
Defines the ID of the current author/user. Set this to the ID of the user who is currently sending messages. Each message in the chat should have an AuthorId that matches this value to indicate that the message was sent by the current user.
Declaration
[Parameter]
public string AuthorId { get; set; }
Property Value
AuthorIdField
Defines the field in the data source that contains the ID of the author of the message.
Declaration
[Parameter]
public string AuthorIdField { get; set; }
Property Value
AuthorImageAltTextField
Defines the field in the data source that contains the alt text for the author's image.
Declaration
[Parameter]
public string AuthorImageAltTextField { get; set; }
Property Value
AuthorImageUrlField
Defines the field in the data source that contains the image URL of the author of the message.
Declaration
[Parameter]
public string AuthorImageUrlField { get; set; }
Property Value
AuthorMessageContentTemplate
Template for modifying the appearance of the messages in the chat. Applied only to author messages. If defined, it takes precedence over MessageContentTemplate.
Declaration
[Parameter]
public RenderFragment<ChatMessageContentTemplateContext<TItem>> AuthorMessageContentTemplate { get; set; }
Property Value
AuthorMessageTemplate
Template for modifying the appearance of the messages bubbles in the chat. Applied only to author messages. If defined, it takes precedence over MessageTemplate.
Declaration
[Parameter]
public RenderFragment<ChatMessageTemplateContext<TItem>> AuthorMessageTemplate { get; set; }
Property Value
AuthorNameField
Defines the field in the data source that contains the name of the author of the message.
Declaration
[Parameter]
public string AuthorNameField { get; set; }
Property Value
ChatFileActions
Defines a render fragment that contains actions for the attachments. Children: ChatFileAction.
Declaration
[Parameter]
public RenderFragment ChatFileActions { get; set; }
Property Value
ChatMessageContextMenuActions
Defines a render fragment that contains message actions. Children: ChatMessageContextMenuAction.
Declaration
[Parameter]
public RenderFragment ChatMessageContextMenuActions { get; set; }
Property Value
ChatMessageToolbarActions
Defines a render fragment that contains actions for the attachments. Children: ChatMessageToolbarAction.
Declaration
[Parameter]
public RenderFragment ChatMessageToolbarActions { get; set; }
Property Value
ChatSettings
Defines a render fragment that contains all settings for the Chat. Children: ChatFileSelectSettings, ChatSpeechToTextButtonSettings, ChatAIClientSettings, ChatAuthorMessageSettings, ChatReceiverMessageSettings, ChatSendMessageButtonSettings and ChatTextAreaSettings.
Declaration
[Parameter]
public RenderFragment ChatSettings { get; set; }
Property Value
Data
The data source for the chat component. The data source should be a collection of items that represent messages.
Declaration
[Parameter]
public IEnumerable<TItem> Data { get; set; }
Property Value
IEnumerable<TItem>
EnableAIChatClient
Enables the built-in integration.
Declaration
[Parameter]
public bool EnableAIChatClient { get; set; }
Property Value
EnableActionButton
Enables or disables the send/action button in the chat input box. When disabled, the button can be manually placed inside an affix template using PromptBoxActionButton.
Declaration
[Parameter]
public bool EnableActionButton { get; set; }
Property Value
EnableFileUpload
Enables or disables the file upload functionality in the chat component. Renders a file upload icon in the chat input box that allows users to upload files.
Declaration
[Parameter]
public bool EnableFileUpload { get; set; }
Property Value
EnableMessageCollapse
Enables the collapse functionality for messages in the chat component. By default, messages are expanded and can be collapsed by clicking on them.
Declaration
[Parameter]
public bool EnableMessageCollapse { get; set; }
Property Value
EnableScrollToBottom
Specifies whether the chat should enable the scroll to bottom button.
Declaration
[Parameter]
public bool EnableScrollToBottom { get; set; }
Property Value
EnableSpeechToText
Enables or disables the speech-to-text functionality in the chat component. Renders a microphone icon in the chat input box that allows users to convert speech to text.
Declaration
[Parameter]
public bool EnableSpeechToText { get; set; }
Property Value
EndIndex
The exclusive end index in the full dataset marking the end of the current batch.
Only relevant in remote mode (OnLoadMoreMessages). Typically StartIndex + Data.Count.
The developer must update this after fetching data and when appending/prepending messages.
EndlessScrollDebounceDelay
The debounce delay in milliseconds for the endless scroll handler. Controls how long the component waits after the user stops scrolling before checking if a new page should be loaded. Default value is 150.
Declaration
[Parameter]
public int EndlessScrollDebounceDelay { get; set; }
Property Value
FilesField
Defines the field in the data source that contains the attachments of the message. The field should be a collection of objects of type FileSelectFileInfo.
Declaration
[Parameter]
public string FilesField { get; set; }
Property Value
HeaderTemplate
Template for modifying the content of the header of the chat component.
Declaration
[Parameter]
public RenderFragment HeaderTemplate { get; set; }
Property Value
Height
Defines the height of the chat component.
IdField
Defines the field in the data source that contains the ID of the message.
InputValue
The value of the chat input field.
Declaration
[Parameter]
public string InputValue { get; set; }
Property Value
IsDeletedField
Defines the field in the data source that indicates whether the message is deleted.
Declaration
[Parameter]
public string IsDeletedField { get; set; }
Property Value
IsFailedField
Defines the field in the data model that indicates whether the message sending has failed.
Declaration
[Parameter]
public string IsFailedField { get; set; }
Property Value
IsPinnedField
Defines the field in the data source that indicates whether the message is deleted.
Declaration
[Parameter]
public string IsPinnedField { get; set; }
Property Value
IsTypingField
Defines the field in the data source that indicates whether the author of the message is currently typing.
Declaration
[Parameter]
public string IsTypingField { get; set; }
Property Value
MessageBoxTemplate
A render fragment that allows customization of the whole message box section in the chat.
Declaration
[Parameter]
public RenderFragment MessageBoxTemplate { get; set; }
Property Value
MessageContentTemplate
Template for modifying the appearance of the messages in the chat.
Declaration
[Parameter]
public RenderFragment<ChatMessageContentTemplateContext<TItem>> MessageContentTemplate { get; set; }
Property Value
MessageFilesLayoutMode
Specifies the layout of the files attached to a message. The available options are:
- Vertical - Files are displayed in a vertical list.
- Horizontal - Files are displayed in a horizontal list.
- Wrap - Files are displayed in a wrapping layout.
The default value is Vertical.
Declaration
[Parameter]
public ChatMessageFilesLayoutMode MessageFilesLayoutMode { get; set; }
Property Value
MessageStatusTemplate
Template for modifying the appearance of the message status indicators in the chat.
Declaration
[Parameter]
public RenderFragment<ChatMessageStatusTemplateContext<TItem>> MessageStatusTemplate { get; set; }
Property Value
MessageTemplate
Template for modifying the appearance of the messages bubbles in the chat.
Declaration
[Parameter]
public RenderFragment<ChatMessageTemplateContext<TItem>> MessageTemplate { get; set; }
Property Value
MessageWidthMode
Defines the width mode of the messages in the chat. The available options are:
- Standard - Messages will have a width that fits their content.
- Full - Messages will take the full width of the chat container.
The default value is Standard.
Declaration
[Parameter]
public MessageWidthMode MessageWidthMode { get; set; }
Property Value
NoDataTemplate
Container for content rendered in place of the message list when no messages or data are provided.
Declaration
[Parameter]
public RenderFragment NoDataTemplate { get; set; }
Property Value
OnDownload
Event callback that is triggered when a file is downloaded. Triggered upon clicking on a file download action or when the Download button is clicked.
Declaration
[Parameter]
public EventCallback<ChatDownloadEventArgs> OnDownload { get; set; }
Property Value
OnInputValueChanged
Event callback that is triggered when the input value changes.
Declaration
[Parameter]
public EventCallback<string> OnInputValueChanged { get; set; }
Property Value
OnLoadMoreMessages
Fires when the component needs a new page of messages (initial load, scroll up/down, scroll to bottom). The developer must update Data, StartIndex, and EndIndex in this handler. Requires Total to be set.
Declaration
[Parameter]
public EventCallback<ChatLoadMoreMessagesEventArgs> OnLoadMoreMessages { get; set; }
Property Value
OnMessageUnpin
Event callback that is triggered when a message is unpinned.
Declaration
[Parameter]
public EventCallback<ChatMessageUnpinEventArgs> OnMessageUnpin { get; set; }
Property Value
OnReferencedMessageClick
Fires when the user clicks a referenced message (pinned message indicator or reply-to preview). In built-in mode, the Chat handles in-DOM navigation automatically — the event is informational. In remote mode, the developer must resolve the message location, fetch data, and update Data, StartIndex, and EndIndex.
Declaration
[Parameter]
public EventCallback<ChatReferencedMessageClickEventArgs> OnReferencedMessageClick { get; set; }
Property Value
OnResendMessage
Event callback that is triggered when a message is sent. The arguments are of type ChatResendMessageEventArgs.
Declaration
[Parameter]
public EventCallback<ChatResendMessageEventArgs> OnResendMessage { get; set; }
Property Value
OnSendMessage
Event callback that is triggered when a message is sent. The arguments are of type ChatSendMessageEventArgs.
Declaration
[Parameter]
public EventCallback<ChatSendMessageEventArgs> OnSendMessage { get; set; }
Property Value
OnSuggestionClick
An event callback that is triggered when a suggestion is selected from the suggestions list. The arguments are of type ChatSuggestionClickEventArgs.
Declaration
[Parameter]
public EventCallback<ChatSuggestionClickEventArgs> OnSuggestionClick { get; set; }
Property Value
PageSize
The number of messages to load per page when ScrollMode is Endless. Default value is 20.
PinnedMessages
A separate collection of pinned messages. Use this when pinned messages may not be part of the currently loaded Data (e.g., in OnLoadMoreMessages scenarios). When not set, the component falls back to looking for pinned messages in Data via the IsPinnedField. The component displays the last item from this collection as the active pinned message.
Declaration
[Parameter]
public IEnumerable<TItem> PinnedMessages { get; set; }
Property Value
IEnumerable<TItem>
Placeholder
Defines the placeholder text displayed in the chat input when it is empty. Use this to provide hints about the expected input to users.
Declaration
[Parameter]
public string Placeholder { get; set; }
Property Value
ReceiverMessageContentTemplate
Template for modifying the appearance of the messages in the chat. Applied only to receiver messages. If defined, it takes precedence over MessageContentTemplate.
Declaration
[Parameter]
public RenderFragment<ChatMessageContentTemplateContext<TItem>> ReceiverMessageContentTemplate { get; set; }
Property Value
ReceiverMessageTemplate
Template for modifying the appearance of the messages bubbles in the chat. Applied only to receiver messages. If defined, it takes precedence over MessageTemplate.
Declaration
[Parameter]
public RenderFragment<ChatMessageTemplateContext<TItem>> ReceiverMessageTemplate { get; set; }
Property Value
RepliedToMessages
Messages that are reply targets for messages in the current batch but live outside Data. Only needed in remote mode (OnLoadMoreMessages). The developer resolves missing reply targets after each data fetch. Scoped per batch — rebuilt on each OnLoadMoreMessages or batch replacement.
Declaration
[Parameter]
public IEnumerable<TItem> RepliedToMessages { get; set; }
Property Value
IEnumerable<TItem>
ReplyToIdField
Each message in the chat should have a unique ID. This field value is optional and it is used to identify the other message to which the current message is a reply.
Declaration
[Parameter]
public string ReplyToIdField { get; set; }
Property Value
ScrollMode
Controls how the Chat handles scrolling and message rendering. Scrollable (default) renders all messages. Endless loads messages in pages as the user scrolls.
Declaration
[Parameter]
public ChatScrollMode ScrollMode { get; set; }
Property Value
StartIndex
The index in the full dataset that Data[0] corresponds to.
Only relevant in remote mode (OnLoadMoreMessages). The developer must update this
after fetching data and when appending/prepending messages.
StatusField
Defines the field in the data source that contains the status of the message.
Declaration
[Parameter]
public string StatusField { get; set; }
Property Value
SuggestedActionsField
Defines the field in the data source that contains the quick actions for the message.
Declaration
[Parameter]
public string SuggestedActionsField { get; set; }
Property Value
SuggestedActionsLayoutMode
Controls the layout of the suggestions displayed below message with suggested actions. The available options are:
- Wrap - Suggestions will wrap to the next line if they exceed the width of the container.
- Scroll - Suggestions will be displayed in a single line with horizontal scrolling.
- ScrollButtons - Suggestions will be displayed in a single line with horizontal scrolling and navigation buttons.
The default value is Wrap.
Declaration
[Parameter]
public ChatSuggestedActionsLayoutMode SuggestedActionsLayoutMode { get; set; }
Property Value
SuggestionTemplate
Template for modifying the appearance of the suggestions displayed in the chat input.
Declaration
[Parameter]
public RenderFragment<ChatSuggestionTemplateContext> SuggestionTemplate { get; set; }
Property Value
Suggestions
Use this parameter to provide a collection of suggestions that will be displayed as quick reply options in the chat input.
Declaration
[Parameter]
public IEnumerable<string> Suggestions { get; set; }
Property Value
SuggestionsLayoutMode
Controls the layout of the suggestions displayed in the chat input. The available options are:
- Wrap - Suggestions will wrap to the next line if they exceed the width of the container.
- Scroll - Suggestions will be displayed in a single line with horizontal scrolling.
- ScrollButtons - Suggestions will be displayed in a single line with horizontal scrolling and navigation buttons.
The default value is Wrap.
Declaration
[Parameter]
public ChatSuggestionsLayoutMode SuggestionsLayoutMode { get; set; }
Property Value
TextField
The field in the data source that contains the text of the message.
Declaration
[Parameter]
public string TextField { get; set; }
Property Value
TimestampField
Defines the field in the data source that contains the timestamp of the message.
Declaration
[Parameter]
public string TimestampField { get; set; }
Property Value
TimestampTemplate
Defines a render fragment that contains the content of the chat time stamps displayed between messages.
Declaration
[Parameter]
public RenderFragment<ChatTimestampTemplateContext> TimestampTemplate { get; set; }
Property Value
Total
The total number of messages in the full dataset. Required when OnLoadMoreMessages has a delegate. Ignored for client-side endless scrolling.
UserStatusTemplate
Content rendered next to the user avatar. Useful for rendering badges indicating user status.
Declaration
[Parameter]
public RenderFragment<ChatMessageUserStatusTemplateContext<TItem>> UserStatusTemplate { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
Overrides
Dispose()
Declaration
public override void Dispose()
Overrides
OnParametersSet()
Declaration
protected override void OnParametersSet()
Overrides
Refresh(bool)
Refreshes the chat component, causing it to re-render.
Declaration
public void Refresh(bool scrollToBottom = true)
Parameters
scrollToBottom
When true, the chat scrolls to the bottom after re-rendering. Default is true.