Sure! Let's create a mock Dashboard in Vue 3 using the most popular component library for Vue 3, which is Element Plus.
✅ What Will Be Included?
- Vue 3 + Vite + Element Plus
- A mock dashboard with:
- Sidebar
- Header
- Cards for Stats
- Chart Placeholder
- Table of Users
1️⃣ Project Setup
First, set up a new Vue 3 app with Vite:
bash
npm init vite@latest vue-dashboard -- --template vue
cd vue-dashboard
npm install
Install Element Plus
bash
npm install element-plus
Add Element Plus to your project
In main.js:
js
// src/main.js
import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
createApp(App).use(ElementPlus).mount('#app')
2️⃣ Create Layout and Components
📁 Project Structure
code
src/
├── components/
│ ├── DashboardHeader.vue
│ ├── DashboardSidebar.vue
│ ├── StatCards.vue
│ ├── UserTable.vue
│ └── ChartPlaceholder.vue
├── App.vue
└── main.js
1. DashboardHeader.vue
vue
<template>
<el-header height="60px" class="bg-white shadow px-4 flex items-center justify-between">
<h2 class="text-lg font-bold">Vue Mock Dashboard</h2>
<el-avatar size="default" icon="el-icon-user" />
</el-header>
</template>
2. DashboardSidebar.vue
vue
<template>
<el-aside width="200px" class="bg-gray-100 h-full">
<el-menu default-active="1" class="el-menu-vertical-demo">
<el-menu-item index="1" icon="el-icon-menu">Dashboard</el-menu-item>
<el-menu-item index="2" icon="el-icon-user">Users</el-menu-item>
<el-menu-item index="3" icon="el-icon-setting">Settings</el-menu-item>
</el-menu>
</el-aside>
</template>
3. StatCards.vue
vue
<template>
<el-row :gutter="20" class="mb-4">
<el-col :span="8" v-for="stat in stats" :key="stat.title">
<el-card>
<h3>{{ stat.title }}</h3>
<p class="text-3xl font-bold">{{ stat.value }}</p>
</el-card>
</el-col>
</el-row>
</template>
<script setup>
const stats = [
{ title: 'Users', value: 1240 },
{ title: 'Sales', value: '$12,400' },
{ title: 'Performance', value: '85%' }
]
</script>
4. UserTable.vue
vue
<template>
<el-table :data="users" style="width: 100%;">
<el-table-column prop="name" label="Name" />
<el-table-column prop="email" label="Email" />
<el-table-column prop="role" label="Role" />
</el-table>
</template>
<script setup>
const users = [
{ name: 'John Doe', email: 'john@example.com', role: 'Admin' },
{ name: 'Jane Smith', email: 'jane@example.com', role: 'Editor' },
{ name: 'Bob Johnson', email: 'bob@example.com', role: 'Viewer' }
]
</script>
5. ChartPlaceholder.vue
vue
<template>
<el-card class="mb-4">
<h3 class="mb-2">Analytics</h3>
<div class="h-48 flex items-center justify-center text-gray-400">
[Chart Placeholder]
</div>
</el-card>
</template>
✅ Later, you can plug in ECharts, Chart.js, or ApexCharts here.
6. App.vue
vue
<template>
<el-container style="height: 100vh">
<DashboardSidebar />
<el-container>
<DashboardHeader />
<el-main class="p-4">
<StatCards />
<ChartPlaceholder />
<UserTable />
</el-main>
</el-container>
</el-container>
</template>
<script setup>
import DashboardHeader from './components/DashboardHeader.vue'
import DashboardSidebar from './components/DashboardSidebar.vue'
import StatCards from './components/StatCards.vue'
import UserTable from './components/UserTable.vue'
import ChartPlaceholder from './components/ChartPlaceholder.vue'
</script>
🔧 Optional: TailwindCSS for Styling
If you want to add utility classes like p-4, flex, etc., install TailwindCSS:
bash
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Add this to tailwind.config.js and src/assets/tailwind.css, then import it into main.js.
✅ Result Preview
This is what your dashboard looks like:
code
+---------------------------------------------+
| 🧭 Sidebar | Header |
| |--------------------------------|
| | 🔢 Stat Cards |
| | 📊 Chart Placeholder |
| | 🧑 User Table |
+---------------------------------------------+
📦 Optional Features To Add
- Dark mode
- Responsive layout
- Real charts using
echarts or apexcharts
- Routing using
vue-router
Would you like me to include charts or routing next?