Appearance in React Inline AI Assist
11 Aug 202617 minutes to read
Component Dimensions
Popup width
You can use the popupWidth property to set the width of the Inline AI Assist. The default value is 400px.
Popup height
You can use the popupHeight property to set the height of the Inline AI Assist. The default value is auto.
Z-index
You can use the zIndex property to set z-index for the Inline AI Assist popup. The default value is 1000.
Custom styling using cssClass
You can customize the appearance of the Inline AI Assist component by using the cssClass property.
Below sample demonstrates the usage of above root level properties in Inline Assist component
import { InlineAIAssistComponent } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const assistRef = React.useRef(null);
const editableRef = React.useRef(null);
const handleSummarizeBtnClick = () => {
if (assistRef.current && typeof assistRef.current.showPopup === 'function') {
assistRef.current.showPopup();
}
};
const handlePromptRequest = () => {
setTimeout(() => {
const defaultResponse = 'For real-time prompt processing, connect the Inline AI Assist 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.';
if (assistRef.current && typeof assistRef.current.addResponse === 'function') {
assistRef.current.addResponse(defaultResponse);
}
}, 1000);
};
const handleResponseItemSelect = (args) => {
if (args.command.label === 'Accept') {
if (editableRef.current && assistRef.current) {
const lastResponse = assistRef.current.prompts && assistRef.current.prompts.length > 0
? assistRef.current.prompts[assistRef.current.prompts.length - 1].response
: '';
if (lastResponse) {
editableRef.current.innerHTML = '<p>' + lastResponse + '</p>';
}
}
if (assistRef.current && typeof assistRef.current.hidePopup === 'function') {
assistRef.current.hidePopup();
}
} else if (args.command.label === 'Discard') {
if (assistRef.current && typeof assistRef.current.hidePopup === 'function') {
assistRef.current.hidePopup();
}
}
};
return (
<div>
<div style=>
<h4 style=>Inline Assist Configuration</h4>
</div>
<button
id="summarizeBtn"
className="e-btn e-primary"
style=
onClick={handleSummarizeBtnClick}
>
Content Summarize
</button>
<div
id="editableText"
contentEditable="true"
ref={editableRef}
>
<p>Inline AI Assist component provides intelligent text processing capabilities that enhance user productivity. It leverages advanced natural language processing to understand context and deliver precise suggestions. Users can seamlessly integrate AI-powered features into their applications.</p>
<p>With real-time response streaming and customizable prompts, developers can create interactive experiences. The component supports multiple response modes including inline editing and popup-based interactions.</p>
</div>
<InlineAIAssistComponent
id="defaultInlineAssist"
ref={assistRef}
relateTo="#summarizeBtn"
popupWidth="650px"
popupHeight="350px"
placeholder="Type your prompt here..."
cssClass="custom-container"
zIndex={4000}
promptRequest={handlePromptRequest}
responseSettings=
/>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('container'));import { InlineAIAssistComponent, ResponseItemSelectEventArgs } from '@syncfusion/ej2-react-interactive-chat';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
const App: React.FC = () => {
const assistRef = React.useRef<InlineAIAssistComponent>(null);
const editableRef = React.useRef<HTMLDivElement>(null);
const handleSummarizeBtnClick = (): void => {
if (assistRef.current && typeof assistRef.current.showPopup === 'function') {
assistRef.current.showPopup();
}
};
const handlePromptRequest = (): void => {
setTimeout(() => {
const defaultResponse = 'For real-time prompt processing, connect the Inline AI Assist 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.';
if (assistRef.current && typeof assistRef.current.addResponse === 'function') {
assistRef.current.addResponse(defaultResponse);
}
}, 1000);
};
const handleResponseItemSelect = (args: ResponseItemSelectEventArgs): void => {
if (args.command.label === 'Accept') {
if (editableRef.current && assistRef.current) {
const lastResponse = assistRef.current.prompts && assistRef.current.prompts.length > 0
? assistRef.current.prompts[assistRef.current.prompts.length - 1].response
: '';
if (lastResponse) {
editableRef.current.innerHTML = '<p>' + lastResponse + '</p>';
}
}
if (assistRef.current && typeof assistRef.current.hidePopup === 'function') {
assistRef.current.hidePopup();
}
} else if (args.command.label === 'Discard') {
if (assistRef.current && typeof assistRef.current.hidePopup === 'function') {
assistRef.current.hidePopup();
}
}
};
return (
<div>
<div style=>
<h4 style=>Inline Assist Configuration</h4>
</div>
<button
id="summarizeBtn"
className="e-btn e-primary"
style=
onClick={handleSummarizeBtnClick}
>
Content Summarize
</button>
<div
id="editableText"
contentEditable="true"
ref={editableRef}
>
<p>Inline AI Assist component provides intelligent text processing capabilities that enhance user productivity. It leverages advanced natural language processing to understand context and deliver precise suggestions. Users can seamlessly integrate AI-powered features into their applications.</p>
<p>With real-time response streaming and customizable prompts, developers can create interactive experiences. The component supports multiple response modes including inline editing and popup-based interactions.</p>
</div>
<InlineAIAssistComponent
id="defaultInlineAssist"
ref={assistRef}
relateTo="#summarizeBtn"
popupWidth="650px"
popupHeight="350px"
placeholder="Type your prompt here..."
cssClass="custom-container"
zIndex={4000}
promptRequest={handlePromptRequest}
responseSettings=
/>
</div>
);
};
ReactDOM.render(<App />, document.getElementById('container'));#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
#container {
margin: 20px auto;
}
#editableText {
width: 100%;
min-height: 120px;
max-height: 300px;
overflow-y: auto;
font-size: 16px;
padding: 12px;
border-radius: 4px;
border: 1px solid;
}
.e-inlineaiassist.custom-container {
border-color: #e0e0e0;
background-color: #f4f4f4;
box-shadow: 3px 3px 10px 0px rgba(0, 0, 0, 0.2);
}
.e-inlineaiassist.custom-container .e-footer .e-toolbar {
background: #d5d5d5;
}