syncfusion-react-chat-ui

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Syncfusion React Chat-UI in Syncfusion React

Syncfusion React Chat-UI in Syncfusion React

Component Overview

组件概述

The Chat-UI component provides a complete conversational interface with real-time messaging, file attachments, user presence, and extensive customization options. This skill guides you through implementing chat interfaces for customer support, team collaboration, and interactive applications.
Chat-UI组件提供了完整的对话界面,支持实时消息、文件附件、用户在线状态以及丰富的定制选项。本技能将指导你为客户支持、团队协作和交互式应用实现聊天界面。

Key Capabilities

核心功能

The Chat-UI component is an interactive messaging interface featuring:
  • Rich Message Support: Text, markdown, formatted content
  • User Management: Multi-user conversations, presence status, avatars
  • File Attachments: Upload, preview, download with restrictions
  • Event System: Lifecycle, interaction, and attachment events
  • Templates: Customizable UI for messages, suggestions, footer
  • Internationalization: Multi-language and RTL support
Chat-UI组件是一个交互式消息界面,具备以下特性:
  • 富消息支持:文本、Markdown、格式化内容
  • 用户管理:多用户对话、在线状态、头像
  • 文件附件:上传、预览、下载及权限限制
  • 事件系统:生命周期、交互和附件相关事件
  • 模板系统:可定制消息、建议、页脚的UI
  • 国际化:多语言和RTL(从右到左)布局支持

Documentation Navigation

文档导航

Getting Started

快速入门

📄 Read: references/getting-started.md
  • Package installation
  • Basic component initialization
  • CSS theming and imports
📄 阅读: references/getting-started.md
  • 包安装
  • 基础组件初始化
  • CSS主题与导入

Message Management

消息管理

📄 Read: references/message-management.md
  • Adding and updating messages
  • Auto-scroll to latest messages
  • Progressive message loading (on-demand)
  • Message configuration (pinned, reply, forward)
  • Message status tracking
  • Message toolbar customization
📄 阅读: references/message-management.md
  • 添加和更新消息
  • 自动滚动到最新消息
  • 渐进式消息加载(按需加载)
  • 消息配置(置顶、回复、转发)
  • 消息状态追踪
  • 消息工具栏定制

User Configuration

用户配置

📄 Read: references/user-configuration.md
  • User model setup
  • Avatar customization
  • User presence status
  • CSS class customization
📄 阅读: references/user-configuration.md
  • 用户模型设置
  • 头像定制
  • 用户在线状态
  • CSS类定制

Events and Interactions

事件与交互

📄 Read: references/events-and-interactions.md
  • Component lifecycle events
  • Message sending events
  • User typing events (with complete event arguments)
  • Attachment upload and click events
  • Toolbar click events
📄 阅读: references/events-and-interactions.md
  • 组件生命周期事件
  • 消息发送事件
  • 用户输入事件(包含完整事件参数)
  • 附件上传与点击事件
  • 工具栏点击事件

Templating System

模板系统

📄 Read: references/templating-system.md
  • Empty chat template
  • Message custom rendering
  • Time break template
  • Typing indicator template
  • Suggestion template
  • Footer template customization
📄 阅读: references/templating-system.md
  • 空聊天模板
  • 消息自定义渲染
  • 时间分段模板
  • 输入指示器模板
  • 建议模板
  • 页脚模板定制

File Attachments

文件附件

📄 Read: references/file-attachments.md
  • Enable attachment support
  • Configure upload endpoints
  • File type and size restrictions
  • Drag-and-drop support
  • Attachment templates (preview and footer)
  • Handle attachment click events
📄 阅读: references/file-attachments.md
  • 启用附件支持
  • 配置上传端点
  • 文件类型与大小限制
  • 拖拽支持
  • 附件模板(预览与页脚)
  • 处理附件点击事件

Header Customization

头部定制

📄 Read: references/header-customization.md
  • Header visibility and text
  • Header icon styling
  • Toolbar configuration
  • Toolbar item types and events
📄 阅读: references/header-customization.md
  • 头部可见性与文本设置
  • 头部图标样式
  • 工具栏配置
  • 工具栏项类型与事件

Appearance and Styling

外观与样式

📄 Read: references/appearance-styling.md
  • Pompact mode layout for dense conversations
  • Claceholder text configuration
  • Width and height customization
  • CSS class application
  • Component-level styling
📄 阅读: references/appearance-styling.md
  • 紧凑模式布局(适用于密集对话)
  • 占位符文本配置
  • 宽高定制
  • CSS类应用
  • 组件级样式设置

Timestamp and Time Breaks

时间戳与时间分段

📄 Read: references/timestamp-and-timebreaks.md
  • Show/hide timestamps
  • Timestamp format customization
  • Time break separators
  • Date-wise organization
📄 阅读: references/timestamp-and-timebreaks.md
  • 显示/隐藏时间戳
  • 时间戳格式定制
  • 时间分段分隔符
  • 按日期组织对话

Typing Indicator

输入指示器

📄 Read: references/typing-indicator.md
  • Show/hide typing indicator
  • Multi-user typing display
  • Typing indicator template customization
📄 阅读: references/typing-indicator.md
  • 显示/隐藏输入指示器
  • 多用户输入显示
  • 输入指示器模板定制

Mention Integration

提及集成

📄 Read: references/mention-integration.md
  • Configure mentionable users
  • Customize mention trigger character
  • Predefined mentions in messages
  • Mention selection events
📄 阅读: references/mention-integration.md
  • 配置可提及用户
  • 定制提及触发字符
  • 消息中的预定义提及
  • 提及选择事件

Globalization and RTL

国际化与RTL布局

📄 Read: references/globalization-rtl.md
  • Localization and language support
  • Right-to-Left (RTL) layout
  • Typing indicator localization
📄 阅读: references/globalization-rtl.md
  • 本地化与语言支持
  • 从右到左(RTL)布局
  • 输入指示器本地化

Quick Start Example

快速开始示例

tsx
import { ChatUIComponent, MessagesDirective, MessageDirective, UserModel } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";

function App() {
    const currentUserModel: UserModel = {
        id: "user1",
        user: "Albert"
    };

    const otherUserModel: UserModel = {
        id: "user2",
        user: "Michale Suyama"
    };

    return (
        <ChatUIComponent user={currentUserModel} headerText="Chat Support">
            <MessagesDirective>
                <MessageDirective text="Hello, how can I help?" author={currentUserModel} />
                <MessageDirective text="I need assistance with my order." author={otherUserModel} />
            </MessagesDirective>
        </ChatUIComponent>
    );
}

ReactDOM.render(<App />, document.getElementById('container'));
tsx
import { ChatUIComponent, MessagesDirective, MessageDirective, UserModel } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";

function App() {
    const currentUserModel: UserModel = {
        id: "user1",
        user: "Albert"
    };

    const otherUserModel: UserModel = {
        id: "user2",
        user: "Michale Suyama"
    };

    return (
        <ChatUIComponent user={currentUserModel} headerText="Chat Support">
            <MessagesDirective>
                <MessageDirective text="Hello, how can I help?" author={currentUserModel} />
                <MessageDirective text="I need assistance with my order." author={otherUserModel} />
            </MessagesDirective>
        </ChatUIComponent>
    );
}

ReactDOM.render(<App />, document.getElementById('container'));

Common Patterns

常见模式

Create a Support Chat Interface

创建客户支持聊天界面

tsx
<ChatUIComponent 
  user={currentUser}
  headerText="Support Chat"
  enableAttachments={true}
  showTimeStamp={true}
  showHeader={true}
  messageToolbarSettings={{ items: ['Copy', 'Reply', 'Delete'] }}
>
  <MessagesDirective>
    {/* messages populate here */}
  </MessagesDirective>
</ChatUIComponent>
tsx
<ChatUIComponent 
  user={currentUser}
  headerText="Support Chat"
  enableAttachments={true}
  showTimeStamp={true}
  showHeader={true}
  messageToolbarSettings={{ items: ['Copy', 'Reply', 'Delete'] }}
>
  <MessagesDirective>
    {/* messages populate here */}
  </MessagesDirective>
</ChatUIComponent>

Add Message Dynamically

动态添加消息

tsx
const chatRef = useRef<ChatUIComponent>(null);

const addNewMessage = () => {
  chatRef.current.addMessage({
    author: userModel,
    text: "Your message here",
    timeStamp: new Date()
  });
};
tsx
const chatRef = useRef<ChatUIComponent>(null);

const addNewMessage = () => {
  chatRef.current.addMessage({
    author: userModel,
    text: "Your message here",
    timeStamp: new Date()
  });
};

Configure Multiple Templates

配置多模板

Implement
messageTemplate
,
emptyChatTemplate
,
timeBreakTemplate
, and
suggestionTemplate
for complete customization.
实现
messageTemplate
emptyChatTemplate
timeBreakTemplate
suggestionTemplate
以完成全面定制。

Key Props

核心属性

PropTypePurpose
user
UserModelCurrent logged-in user
messages
MessageModel[]Initial message list
headerText
stringHeader title
placeholder
stringInput field hint
enableAttachments
booleanFile upload support
showTimeStamp
booleanDisplay message timestamps
showHeader
booleanShow header section
showFooter
booleanShow input footer
autoScrollToBottom
booleanAuto-scroll to latest message
loadOnDemand
booleanProgressive message loading
enableCompactMode
booleanLeft-aligned compact layout
enableRtl
booleanRight-to-left layout
locale
stringLanguage/culture code
属性类型用途
user
UserModel当前登录用户
messages
MessageModel[]初始消息列表
headerText
string头部标题
placeholder
string输入框提示文本
enableAttachments
boolean文件上传支持
showTimeStamp
boolean显示消息时间戳
showHeader
boolean显示头部区域
showFooter
boolean显示输入页脚
autoScrollToBottom
boolean自动滚动到最新消息
loadOnDemand
boolean渐进式消息加载
enableCompactMode
boolean左对齐紧凑布局
enableRtl
boolean从右到左布局
locale
string语言/区域代码

Common Use Cases

常见使用场景

Use Case 1: Customer Support Chat
  • Multiple support agents handling customer queries
  • File attachment for screenshots and auto-scroll
  • Typing indicators to show agent engagement
  • Progressive loading for long conversation histories
  • Typing indicators to show agent engagement
Use Case 2: Team Collaboration
  • Mention team members with @
  • Compact mode for group conversations
  • Pin important discussions
  • Forward messages for reference
  • Message editing and deletion
Use Case 3: Multilingual Chat Application
  • RTL support for Arabic/Hebrew
  • Localized UI strings
  • Support for multiple cultures

For complete examples and advanced scenarios, explore individual reference files above.
场景1:客户支持聊天
  • 多位支持专员处理客户咨询
  • 支持截图附件与自动滚动
  • 输入指示器显示专员正在回复
  • 长对话历史的渐进式加载
  • 输入指示器显示专员正在回复
场景2:团队协作
  • 使用@提及团队成员
  • 群组对话的紧凑模式
  • 置顶重要讨论
  • 转发消息用于参考
  • 消息编辑与删除
场景3:多语言聊天应用
  • 阿拉伯语/希伯来语的RTL支持
  • 本地化UI文本
  • 支持多区域文化

如需完整示例和高级场景,请探索上述各个参考文档。