DEV Community

Cover image for How to Build a Modern React Admin Dashboard from Scratch (Vite + CSS + SVG)
marop2
marop2

Posted on

How to Build a Modern React Admin Dashboard from Scratch (Vite + CSS + SVG)

Building an admin dashboard doesn't have to be a drag. You don't always need heavy component libraries or complex state management for a clean, fast, and beautiful interface.

In this tutorial, we'll explore the core concepts of building a modern admin dashboard using React, Vite, and vanilla CSS for styling, with SVG for lightweight charts.

Why Vite?

Vite has become the standard for modern React development. It offers lightning-fast Hot Module Replacement (HMR) and optimized builds out of the box.

npm create vite@latest aura-dashboard -- --template react
cd aura-dashboard
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

The Layout Structure

A standard admin dashboard consists of three main areas:

  1. Sidebar (Navigation): For switching between views.
  2. Header (Top bar): For search, notifications, and user profile.
  3. Main Content Area: Where the data lives.

Using CSS Grid makes this layout trivial:

.app-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: 70px 1fr;
  height: 100vh;
}

.sidebar {
  grid-row: 1 / 3;
  grid-column: 1 / 2;
  background: #111827;
  color: white;
}

.header {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  border-bottom: 1px solid #e5e7eb;
}

.main-content {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  background: #f3f4f6;
  padding: 2rem;
  overflow-y: auto;
}
Enter fullscreen mode Exit fullscreen mode

Designing the Cards

The core visual component of any dashboard is the "Card" component. It holds stats, charts, or tables. To make them pop, we use a subtle shadow and rounded corners:

.card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
Enter fullscreen mode Exit fullscreen mode

Lightweight Charts with SVG

Instead of pulling in a massive charting library like Chart.js or Recharts, for simple sparklines or bar charts, you can use pure SVG! It's incredibly lightweight and completely customizable via CSS.

const Sparkline = ({ data }) => {
  // Normalize data to fit within viewBox 0 0 100 30
  // ... math logic ...
  return (
    <svg viewBox="0 0 100 30" width="100%" height="100%">
      <polyline
        fill="none"
        stroke="#3b82f6"
        strokeWidth="2"
        points="0,30 20,15 40,25 60,10 80,20 100,5"
      />
    </svg>
  );
};
Enter fullscreen mode Exit fullscreen mode

Don't Want to Build From Scratch?

If you want a production-ready, beautifully designed React Admin Dashboard out of the box, check out my Aura React Admin Template.

It includes:

  • 🎨 Fully responsive, modern design
  • 📊 Custom lightweight SVG charts
  • 🌙 Dark mode ready
  • âš¡ Built with Vite for maximum speed
  • 🧩 Clean, component-based architecture

👉 Get the Template on Gumroad

Building your own dashboard is a great learning experience, but sometimes you just need to ship faster. Happy coding!

Top comments (0)