Contents
- Show or hide typing indicator
- Typing indicator template
Having trouble getting help?
Contact Support
Contact Support
Typing indicator in EJ2 JavaScript Chat UI control
17 Dec 20243 minutes to read
Show or hide typing indicator
You can use the typingUsers property to display the current user’s who are typing to indicate the active participants typing response within the chat conversations. If the property is empty the typing indicators will be removed.
The typing users are the UserModel[]
collection, where you can update the user’s dynamically to display the current typing user.
ej.base.enableRipple(true);
let currentUserModel = {
id: "user1",
user: "Albert"
};
let michaleUserModel = {
id: "user2",
user: "Michale Suyama"
};
let typingUsers = [michaleUserModel];
let chatMessages = [
{
author: currentUserModel,
text: "Hi Michale, are we on track for the deadline?"
},
{
author: michaleUserModel,
text: "Yes, the design phase is complete."
},
{
author: currentUserModel,
text: "I’ll review it and send feedback by today."
}
];
// Initializes the Chat UI control
let chatUI = new ej.interactivechat.ChatUI({
messages: chatMessages,
user: currentUserModel,
typingUsers: typingUsers
});
// Render initialized Chat UI.
chatUI.appendTo('#typingUsers');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Chat UI</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="TypeScript Chat UI Control" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-inputs/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-buttons/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-navigations/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-popups/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-interactive-chat/styles/material.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 380px; width: 450px;">
<div id="typingUsers"></div>
</div>
</body>
</html>
Typing indicator template
Refer to the Templates section for more details about the typing indicator template.