Appearance in Angular AI AssistView component
22 Aug 20256 minutes to read
The Syncfusion AI AssistView for Angular allows for customization of its dimensions and overall look and feel. This can be achieved by setting the component’s width and height or by applying custom CSS styles.
Setting Component Width
The width property allows you to define the width of the AI AssistView container. You can set this value as a string, using either pixels (e.g., "500px") or a percentage (e.g., "50%"). By default, the width is set to 100%, allowing it to fill its parent container.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AIAssistViewModule } from '@syncfusion/ej2-angular-interactive-chat';
import { Component, HostListener, ViewChild } from '@angular/core';
import { AIAssistViewComponent } from '@syncfusion/ej2-angular-interactive-chat';
@Component({
imports: [ FormsModule, ReactiveFormsModule, AIAssistViewModule ],
standalone: true,
selector: 'app-root',
// specifies the template string for the AI AssistView component
template: `<div ejs-aiassistview #aiAssistViewComponent (promptRequest)="onPromptRequest()" [width]="width"></div>`
})
export class AppComponent {
@ViewChild('aiAssistViewComponent')
public aiAssistViewComponent!: AIAssistViewComponent;
public width: string = '650px';
public onPromptRequest = () => {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AIAssistView component to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
this.aiAssistViewComponent.addPromptResponse(defaultResponse);
}, 1000);
};
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Setting Component Height
The height property allows you to define the height of the AI AssistView container. This value can be a string, specified in pixels (e.g., "600px") or as a percentage (e.g., "100%"). The default value is 100%.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AIAssistViewModule } from '@syncfusion/ej2-angular-interactive-chat';
import { Component, HostListener, ViewChild } from '@angular/core';
import { AIAssistViewComponent } from '@syncfusion/ej2-angular-interactive-chat';
@Component({
imports: [ FormsModule, ReactiveFormsModule, AIAssistViewModule ],
standalone: true,
selector: 'app-root',
// specifies the template string for the AI AssistView component
template: `<div ejs-aiassistview #aiAssistViewComponent (promptRequest)="onPromptRequest()" [height]="height"></div>`
})
export class AppComponent {
@ViewChild('aiAssistViewComponent')
public aiAssistViewComponent!: AIAssistViewComponent;
public height: string = '350px';
public onPromptRequest = () => {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AIAssistView component to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
this.aiAssistViewComponent.addPromptResponse(defaultResponse);
}, 1000);
};
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));Applying Custom CSS Styles
For more advanced style customizations, you can use the cssClass property to apply one or more custom CSS classes to the AI AssistView component’s root element.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AIAssistViewModule } from '@syncfusion/ej2-angular-interactive-chat';
import { Component, HostListener, ViewChild } from '@angular/core';
import { AIAssistViewComponent } from '@syncfusion/ej2-angular-interactive-chat';
@Component({
imports: [ FormsModule, ReactiveFormsModule, AIAssistViewModule ],
standalone: true,
selector: 'app-root',
// specifies the template string for the AI AssistView component
template: `<div ejs-aiassistview id="cssClass" #aiAssistViewComponent (promptRequest)="onPromptRequest()" [cssClass]="cssClass"></div>`
})
export class AppComponent {
@ViewChild('aiAssistViewComponent')
public aiAssistViewComponent!: AIAssistViewComponent;
public cssClass: string = 'custom-container';
public onPromptRequest = () => {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AIAssistView component to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
this.aiAssistViewComponent.addPromptResponse(defaultResponse);
}, 1000);
};
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));