Appearance in React AI AssistView component
28 Aug 202511 minutes to read
The Syncfusion AI AssistView for React 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 { AIAssistViewComponent } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
const assistInstance = React.useRef(null);
const onPromptRequest = (args) => {
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.';
assistInstance.current.addPromptResponse(defaultResponse);
}, 1000);
};
return (
// specifies the tag for render the AI AssistView component
<AIAssistViewComponent id="aiAssistView" ref={assistInstance} promptRequest={onPromptRequest} width={'650px'}></AIAssistViewComponent>
);
}
ReactDOM.render(<App />, document.getElementById('container'));import { AIAssistViewComponent, PromptRequestEventArgs } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
const assistInstance = React.useRef<AIAssistViewComponent>(null);
const onPromptRequest = (args: PromptRequestEventArgs) => {
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.';
assistInstance.current.addPromptResponse(defaultResponse);
}, 1000);
};
return (
// specifies the tag for render the AI AssistView component
<AIAssistViewComponent id="aiAssistView" ref={assistInstance} promptRequest={onPromptRequest} width={'650px'}></AIAssistViewComponent>
);
}
ReactDOM.render(<App />, document.getElementById('container'));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 { AIAssistViewComponent } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
const assistInstance = React.useRef(null);
const onPromptRequest = (args) => {
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.';
assistInstance.current.addPromptResponse(defaultResponse);
}, 1000);
};
return (
// specifies the tag for render the AI AssistView component
<AIAssistViewComponent id="aiAssistView" ref={assistInstance} promptRequest={onPromptRequest} height={'350px'}></AIAssistViewComponent>
);
}
ReactDOM.render(<App />, document.getElementById('container'));import { AIAssistViewComponent, PromptRequestEventArgs } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
const assistInstance = React.useRef<AIAssistViewComponent>(null);
const onPromptRequest = (args: PromptRequestEventArgs) => {
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.';
assistInstance.current.addPromptResponse(defaultResponse);
}, 1000);
};
return (
// specifies the tag for render the AI AssistView component
<AIAssistViewComponent id="aiAssistView" ref={assistInstance} promptRequest={onPromptRequest} height={'350px'}></AIAssistViewComponent>
);
}
ReactDOM.render(<App />, document.getElementById('container'));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 { AIAssistViewComponent } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
const assistInstance = React.useRef(null);
const onPromptRequest = (args) => {
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.';
assistInstance.current.addPromptResponse(defaultResponse);
}, 1000);
};
return (
// specifies the tag for render the AI AssistView component
<AIAssistViewComponent id="aiAssistView" ref={assistInstance} promptRequest={onPromptRequest} cssClass={'custom-container'}></AIAssistViewComponent>
);
}
ReactDOM.render(<App />, document.getElementById('container'));import { AIAssistViewComponent, PromptRequestEventArgs } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from "react-dom";
function App() {
const assistInstance = React.useRef<AIAssistViewComponent>(null);
const onPromptRequest = (args: PromptRequestEventArgs) => {
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.';
assistInstance.current.addPromptResponse(defaultResponse);
}, 1000);
};
return (
// specifies the tag for render the AI AssistView component
<AIAssistViewComponent id="aiAssistView" ref={assistInstance} promptRequest={onPromptRequest} cssClass={'custom-container'}></AIAssistViewComponent>
);
}
ReactDOM.render(<App />, document.getElementById('container'));/* Represents the styles for loader */
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
#container {
margin: 20px auto;
}
.e-aiassistview.custom-container {
border-color: #e0e0e0;
background-color: #f4f4f4;
box-shadow: 3px 3px 10px 0px rgba(0, 0, 0, 0.2);
}
.e-aiassistview.custom-container .e-view-header .e-toolbar, .e-aiassistview.custom-container .e-view-header .e-toolbar-items {
background: #d5d5d5;
}
.e-aiassistview.custom-container .e-view-content .e-footer .e-input-group {
border: 3px solid #e0e0e0 !important;
}