Getting Started with the Vue Chat UI component in Vue 2
30 Jun 20267 minutes to read
This article provides a step-by-step guide for setting up a Vue 2 project using Vue-CLI and integrating the Syncfusion® Vue Chat UI component using the Composition API / Options API.
Prerequisites
System requirements for Syncfusion® Vue UI components
Setting up the Vue 2 project
To generate a Vue 2 project using Vue-CLI, use the vue create command. Follow these steps to install Vue CLI and create a new project:
npm install -g @vue/cli
vue create quickstart
cd quickstart
npm run serveor
yarn global add @vue/cli
vue create quickstart
cd quickstart
yarn run serveWhen creating a new project, choose the option Default ([Vue 2] babel, eslint) from the menu.

Once the quickstart project is set up with default settings, proceed to add Syncfusion® components to the project
Add Syncfusion® Vue packages
Syncfusion® packages are available at npmjs.com. To use Vue components, install the required npm package.
This article uses the Vue Chat UI component as an example. Install the @syncfusion/ej2-vue-interactive-chat package by running the following command:
npm install @syncfusion/ej2-vue-interactive-chat --saveor
yarn add @syncfusion/ej2-vue-interactive-chatImport Syncfusion® CSS styles
You can import themes for the Syncfusion® Vue component in various ways, such as using CSS or SASS styles from npm packages, CDN, CRG and Theme Studio. Refer to themes topic to know more about built-in themes and different ways to refer to themes in a Vue project.
To install the tailwind3 theme package, use the following command:
npm install @syncfusion/ej2-tailwind3-theme --saveTo render the Chat UI component, import the required Tailwind3 CSS styles for the component and its dependencies into the <style> section of the src/App.vue file. This approach ensures that all necessary dependency styles are loaded, as shown below.
<style>
@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/chat-ui/index.css";
</style>Add Syncfusion® Vue component
Follow the below steps to add the Vue Chat UI component using Composition API or Options API:
1. First, import and register the Chat UI component in the script section of the src/App.vue file. If you are using the Composition API, you should add the setup attribute to the script tag to indicate that Vue will be using the Composition API.
<script setup>
import { ChatUIComponent as EjsChatui } from "@syncfusion/ej2-vue-interactive-chat";
const currentUser = {
id: "user",
user: "Albert"
};
</script><script>
import { ChatUIComponent } from "@syncfusion/ej2-vue-interactive-chat";
export default {
components: {
'ejs-chatui': ChatUIComponent
},
data () {
return {
currentUser: {
id: "user1",
user: "Current User",
}
}
}
}
</script>2. In the template section, define the Chat UI component.
<template>
<div id="app">
<div id='container' style="height: 400px; width: 400px;">
<ejs-chatui :user="currentUser"></ejs-chatui>
</div>
</div>
</template>Run the application
To run the application, use the following command:
npm run serveor
yarn run serveConfigure messages and user
To define the chat content, use the <e-messages> tag to group all messages, and the <e-message> tag for each individual message. The user property assigns an identity to the current user, which is essential for distinguishing the user’s messages from those of other participants.
<template>
<div id='container' style="height: 380px; width: 450px; margin: 0 auto;">
<ejs-chatui :user="currentUser">
<e-messages>
<e-message :author="currentUser" text="Hi Michale, are we on track for the deadline?"></e-message>
<e-message :author="michaleUser" text="Yes, the design phase is complete."></e-message>
<e-message :author="currentUser" text="I’ll review it and send feedback by today."></e-message>
</e-messages>
</ejs-chatui>
</div>
</template>
<script setup>
import { ChatUIComponent as EjsChatui, MessagesDirective as EMessages, MessageDirective as EMessage } from "@syncfusion/ej2-vue-interactive-chat";
const currentUser = {
id: "user1",
user: "Albert"
};
const michaleUser = {
id: "user2",
user: "Michale Suyama"
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-interactive-chat/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css";
</style><template>
<div id='container' style="height: 380px; width: 450px; margin: 0 auto;">
<ejs-chatui :user="currentUser">
<e-messages>
<e-message :author="currentUser" text="Hi Michale, are we on track for the deadline?"></e-message>
<e-message :author="michaleUser" text="Yes, the design phase is complete."></e-message>
<e-message :author="currentUser" text="I’ll review it and send feedback by today."></e-message>
</e-messages>
</ejs-chatui>
</div>
</template>
<script>
import { ChatUIComponent, MessagesDirective, MessageDirective } from "@syncfusion/ej2-vue-interactive-chat";
export default {
components: {
'ejs-chatui': ChatUIComponent,
'e-messages': MessagesDirective,
'e-message': MessageDirective
},
data() {
return {
currentUser: {
id: "user1",
user: "Albert",
},
michaleUser: {
id: "user2",
user: "Michale Suyama",
}
};
},
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-interactive-chat/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css";
</style>