- Show or hide header
- Toolbar
Contact Support
Header in Angular Chat UI component
21 Jan 202524 minutes to read
Show or hide header
You can use showHeader property to enable or disable the chat header. It contains the following options headerText and headerIconCss.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [showHeader]="false">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting header text
You can use the headerText property to display the text that appears in the header, which indicates the current username or the group name providing the context for the conversation.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" headerText="Michale">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting header icon CSS
You can use the headerIconCss property to customize the styling of the header icon.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" headerIconCss="e-icons e-people">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Toolbar
You can render the Chat UI toolbar items by using the items
property in the headerToolbar.
Setting Items
Items can be constructed with the following built-in command types or item template.
Adding icon CSS
You can customize the header toolbar icons by using the iconCss
property.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [{ iconCss: 'e-icons e-menu', align: 'Right' }]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting item type
You can change the header toolbar item type by using the type
property. The type
supports three types of items such as Button
, Separator
and Input
. By default, the type is Button
.
In the following example, header toolbar item type is set as Button
.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [{ iconCss: 'e-icons e-refresh', align: 'Right', type: 'Button' }]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting text
You can use the text
property to set the text for the header toolbar item.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [{ text: 'Log Out', align: 'Right' }]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Show or hide toolbar item
You can use the visible
property to specify whether to show or hide the header toolbar item. By default, its value is true
.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [
{ iconCss: 'e-icons e-refresh', align: 'Right', visible: false },
{ iconCss: 'e-icons e-user', align: 'Right' }
]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting disabled
You can use the disabled
property to disable the header toolbar item. By default, its value is false
.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [
{ iconCss: 'e-icons e-refresh', align: 'Right', disabled: true },
{ iconCss: 'e-icons e-user', align: 'Right' }
]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting tooltip text
You can use the tooltip
property to specify the tooltip text to be displayed on hovering the header toolbar item.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [{ iconCss: 'e-icons e-refresh', align: 'Right', tooltip: 'Refresh' }]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting Css Class
You can use the cssClass
property to customize the header toolbar item.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [ { iconCss: 'e-icons e-user', align: 'Right', cssClass: 'custom-btn' } ]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Setting alignment
You can change the alignment of toolbar item by using the align
property. It supports three types of alignments such as Left
, Center
and Right
. By default, the value is Left
.
In the following example, toolbar item type is set with Right
.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [{ iconCss: 'e-icons e-menu', align: 'Right' }]
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Enabling tab key navigation in toolbar
You can use the tabIndex
property of a Toolbar item to enable tab key navigation for the item. By default, the user can switch between items using the arrow keys, but the tabIndex
property allows you to switch between items using the Tab
and Shift+Tab
keys as well.
To use the tabIndex
property, set it for each Toolbar item which you want to enable tab key navigation. The tabIndex
property should be set to a positive integer value. A value of 0
or a negative value will disable tab key navigation for the item.
For example, to enable tab key navigation for two Toolbar items you can use the following code:
import { Component, ViewChild } from '@angular/core';
import { ChatUIComponent, ToolbarSettingsModel } from '@syncfusion/ej2-angular-interactive-chat';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
// specifies the template string for the Chat UI component
template: `<div ejs-chatui #chatUI [headerToolbar]="headerToolbar"></div>`
})
export class AppComponent {
@ViewChild('chatUIComponent')
public chatUIComponent!: ChatUIComponent;
public headerToolbar: ToolbarSettingsModel = {
items: [
{ text: "Item 1", tabIndex: 1 },
{ text: "Item 2", tabIndex: 2 }
]
};
}
With the above code, the user can switch between the two Toolbar items using the Tab and Shift+Tab keys, in addition to using the arrow keys. The items will be navigated in the order specified by the tabIndex
values.
If you set the tabIndex
value to 0 for all Toolbar items, tab key navigation will be based on the element order rather than the tabIndex
values. For example:
import { Component, ViewChild } from '@angular/core';
import { ChatUIComponent, ToolbarSettingsModel } from '@syncfusion/ej2-angular-interactive-chat';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
// specifies the template string for the Chat UI component
template: `<div ejs-chatui #chatUI [headerToolbar]="headerToolbar"></div>`
})
export class AppComponent {
@ViewChild('chatUIComponent')
public chatUIComponent!: ChatUIComponent;
public headerToolbar: ToolbarSettingsModel = {
items: [
{ text: "Item 1", tabIndex: 0 },
{ text: "Item 2", tabIndex: 0 }
]
};
}
In this case, the user can switch between the two Toolbar items using the Tab and Shift+Tab keys, and the items will be navigated in the order in which they appear in the DOM.
Setting template
You can use the template
property to add custom toolbar item in the Chat UI component.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { DropDownButton } from '@syncfusion/ej2-angular-splitbuttons';
import { UserModel, ToolbarSettingsModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [
{
type: 'Input', align: 'Right',
template: '<button id="ddMenu"></button>'
}
]
};
public dropdownItems = [
{
text: 'Info'
},
{
text: 'Search'
},
{
text: 'Add to list'
},
{
text: 'Mute'
}
];
public created = () => {
var dropdown: DropDownButton = new DropDownButton({
items: this.dropdownItems,
content: 'Menu',
iconCss: 'e-icons e-menu',
cssClass: "custom-dropdown"
}, '#ddMenu');
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar" (created)="created()">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Item clicked
You can define itemClicked
event in the headerToolbar
property which will be triggered when the header toolbar item is clicked.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, ToolbarSettingsModel, ToolbarItemClickedEventArgs } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public headerToolbar: ToolbarSettingsModel = {
items: [{ iconCss: 'e-icons e-refresh', align: 'Right' }],
itemClicked: (args: ToolbarItemClickedEventArgs) => {
// Your required action here
}
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [headerToolbar]="headerToolbar">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>