Building a financial dashboard with HTML5, TailwindCSS v4, and Vanilla JavaScript

Introduction While developing the Financial data analyzer series, a dashboard became necessary for presenting the analyzed data intuitively and visually appealingly. Although I'm not a UI/UX designer, I appreciate well-designed interfaces with modern visual cues. This article details my process of creating such a dashboard from scratch with TailwindCSS v4 without using external frameworks. Prerequisite This article assumes you're familiar with HTML5, CSS3, and JavaScript (ES syntax). Familiarity with TailwindCSS is also helpful. I'll present two ways to set up your development environment for working with TailwindCSS from scratch, without external frameworks. Setup for Tailwind CSS v4 for Node.js users To get started with Tailwind CSS v4 for your dashboard project using Node.js, follow these steps: Create your project directory (e.g., finance-dashboard) and navigate into it: mkdir finance-dashboard cd finance-dashboard Install Tailwind CSS, the Tailwind CSS CLI, and the @tailwindcss/forms plugin as development dependencies: npm install -D tailwindcss @tailwindcss/cli @tailwindcss/forms Create an input CSS file (e.g., assets/css/input.css) and add the following: @import "tailwindcss"; @plugin "@tailwindcss/forms"; @custom-variant dark (&:where(.dark, .dark *)); @layer base { html { scroll-behavior: smooth; } body { overflow-y: scroll; font-family: "Fira Sans", sans-serif; } input[type], textarea, select { @apply appearance-none border-none ring-0 outline-hidden; &:focus { @apply border-none ring-0 outline-hidden; } &:focus-visible { @apply border-none ring-0 outline-hidden; } } button { @apply cursor-pointer; } } This CSS file imports Tailwind CSS, registers the @tailwindcss/forms plugin and sets up a custom dark variant for enabling dark mode via CSS classes. It also includes basic styling for smooth scrolling, font family, and form elements. Note: TailwindCSS v4 We are using strictly TailwindCSS v4 here hence we ditched tailwind.config.[j|t]s file. You can read more in my v3 to v4 migration guide with plugins. Create your main HTML file (e.g., index.html) with the following structure: Dashboard | John Owolabi Idogun This is a basic HTML structure that includes Google Fonts, ApexCharts (for placeholder charts), and links to your compiled CSS and JavaScript files. The body includes classes for light and dark modes. Generate the compiled CSS file, assets/css/style.css: npx tailwindcss -i ./assets/css/input.css -o ./assets/css/style.css --watch --minify Tailwind CSS v4 Setup without Node.js For those who prefer not to use Node.js, you can use TailwindCSS's Standalone CLI. Follow the guide to install it based on your operating system. Then, complete steps 1, 3, and 4 from the Node.js setup, skipping steps 2 and 5. To compile your CSS, run: ./tailwindcss -i input.css -o output.css --watch --minify This setup provides a foundation for building the dashboard with Tailwind CSS v4, utilizing vanilla JavaScript for interactivity and ApexCharts for data visualization. Source code Sirneij / finance-dashboard An aesthetic personal finance dashboard built with vanilla JS, tailwindcss v4 and HTML5 Finance Dashboard A responsive financial dashboard built with HTML, Tailwind CSS v4, and vanilla JavaScript. Features Responsive Design: Adapts seamlessly between mobile and desktop views Collapsible Sidebar: Full-width and compact viewing options Dark Mode Support: Automatic system theme detection with manual toggle Real-time Data Visualization: Using ApexCharts for financial data display Mobile-First Approach: Optimized for all screen sizes Project Structure finance-dashboard/ ' ├── README ├── assets │ ├── css │ │ ├── input.css │ │ └── style.css │ ├── images │ │ ├── favicons │ │ │ ├── apple-touch-icon.png │ │ │ ├── favicon-96x96.png │ │ │ ├── favicon.ico │ │ │ ├── favicon.svg │ │ │ ├── site.webmanifest │ │ │ ├── web-app-manifest-192x192.png │ │ │ └── web-app-manifest-512x512.png │ │ ├── logo-small.svg │ │ └── logo.svg │ └── js │ ├── app.js │ └── index.charts.js ├── index.html ├── package-lock.json ├── package.json └── pages ├── behavior.html └── transactions.html Getting Started… View on GitHub Implementation Step 1: Header and Sidebar First off, we will build out the header and sidebar of the dashboard. Let's add this to the body of the page: Overview

Feb 11, 2025 - 18:14
 0
Building a financial dashboard with HTML5, TailwindCSS v4, and Vanilla JavaScript

Introduction

While developing the Financial data analyzer series, a dashboard became necessary for presenting the analyzed data intuitively and visually appealingly. Although I'm not a UI/UX designer, I appreciate well-designed interfaces with modern visual cues. This article details my process of creating such a dashboard from scratch with TailwindCSS v4 without using external frameworks.

Prerequisite

This article assumes you're familiar with HTML5, CSS3, and JavaScript (ES syntax). Familiarity with TailwindCSS is also helpful.

I'll present two ways to set up your development environment for working with TailwindCSS from scratch, without external frameworks.

Setup for Tailwind CSS v4 for Node.js users

To get started with Tailwind CSS v4 for your dashboard project using Node.js, follow these steps:

  1. Create your project directory (e.g., finance-dashboard) and navigate into it:

    mkdir finance-dashboard
    cd finance-dashboard
    
  2. Install Tailwind CSS, the Tailwind CSS CLI, and the @tailwindcss/forms plugin as development dependencies:

    npm install -D tailwindcss @tailwindcss/cli @tailwindcss/forms
    
  3. Create an input CSS file (e.g., assets/css/input.css) and add the following:

    @import "tailwindcss";
    @plugin "@tailwindcss/forms";
    
    @custom-variant dark (&:where(.dark, .dark *));
    
    @layer base {
      html {
        scroll-behavior: smooth;
      }
    
      body {
        overflow-y: scroll;
        font-family: "Fira Sans", sans-serif;
      }
    
      input[type],
      textarea,
      select {
        @apply appearance-none border-none ring-0 outline-hidden;
    
        &:focus {
          @apply border-none ring-0 outline-hidden;
        }
    
        &:focus-visible {
          @apply border-none ring-0 outline-hidden;
        }
      }
    
      button {
        @apply cursor-pointer;
      }
    }
    

    This CSS file imports Tailwind CSS, registers the @tailwindcss/forms plugin and sets up a custom dark variant for enabling dark mode via CSS classes. It also includes basic styling for smooth scrolling, font family, and form elements. Note: TailwindCSS v4

    We are using strictly TailwindCSS v4 here hence we ditched tailwind.config.[j|t]s file. You can read more in my v3 to v4 migration guide with plugins.

  4. Create your main HTML file (e.g., index.html) with the following structure:

    
     lang="en">
      
         charset="UTF-8" />
         name="viewport" content="width=device-width, initial-scale=1.0" />
        </span>Dashboard | John Owolabi Idogun<span class="nt">
        
         rel="preconnect" href="https://fonts.googleapis.com" />
         rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
        
          href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
          rel="stylesheet"
        />
        
        
        
         rel="stylesheet" href="./assets/css/style.css" />
      
       class="bg-white text-black dark:bg-gray-900 dark:text-white">
        
        
        
      
    
    

    This is a basic HTML structure that includes Google Fonts, ApexCharts (for placeholder charts), and links to your compiled CSS and JavaScript files. The body includes classes for light and dark modes.

  5. Generate the compiled CSS file, assets/css/style.css:

    npx tailwindcss -i ./assets/css/input.css -o ./assets/css/style.css --watch --minify
    

Tailwind CSS v4 Setup without Node.js

For those who prefer not to use Node.js, you can use TailwindCSS's Standalone CLI. Follow the guide to install it based on your operating system. Then, complete steps 1, 3, and 4 from the Node.js setup, skipping steps 2 and 5. To compile your CSS, run:

./tailwindcss -i input.css -o output.css --watch --minify

This setup provides a foundation for building the dashboard with Tailwind CSS v4, utilizing vanilla JavaScript for interactivity and ApexCharts for data visualization.

Source code

GitHub logo Sirneij / finance-dashboard

An aesthetic personal finance dashboard built with vanilla JS, tailwindcss v4 and HTML5

Finance Dashboard

A responsive financial dashboard built with HTML, Tailwind CSS v4, and vanilla JavaScript.

Features

  • Responsive Design: Adapts seamlessly between mobile and desktop views
  • Collapsible Sidebar: Full-width and compact viewing options
  • Dark Mode Support: Automatic system theme detection with manual toggle
  • Real-time Data Visualization: Using ApexCharts for financial data display
  • Mobile-First Approach: Optimized for all screen sizes

Project Structure

finance-dashboard/
'
├── README
├── assets
│   ├── css
│   │   ├── input.css
│   │   └── style.css
│   ├── images
│   │   ├── favicons
│   │   │   ├── apple-touch-icon.png
│   │   │   ├── favicon-96x96.png
│   │   │   ├── favicon.ico
│   │   │   ├── favicon.svg
│   │   │   ├── site.webmanifest
│   │   │   ├── web-app-manifest-192x192.png
│   │   │   └── web-app-manifest-512x512.png
│   │   ├── logo-small.svg
│   │   └── logo.svg
│   └── js
│       ├── app.js
│       └── index.charts.js
├── index.html
├── package-lock.json
├── package.json
└── pages
    ├── behavior.html
    └── transactions.html

Getting Started

Implementation

Step 1: Header and Sidebar

First off, we will build out the header and sidebar of the dashboard. Let's add this to the body of the page:


  class="relative h-screen overflow-hidden bg-gray-100 dark:bg-gray-900"
  id="main-content"
>
  
  
    id="sidebar"
    class="fixed inset-y-0 left-0 z-30 transform bg-white transition-all duration-300 dark:bg-gray-800"
  >
     class="flex h-16 items-center justify-between px-4">
       class="flex items-center" href="/">
        
          id="logo"
          src="./assets/images/logo.svg"
          alt="Logo"
          class="h-12 w-auto"
        />
      
      
        onclick="sidebarController.toggle()"
        class="rounded-sm p-1 hover:bg-gray-100 dark:hover:bg-gray-700"
        aria-label="Toggle sidebar"
      >
        
          class="h-6 w-6 text-gray-600 dark:text-gray-300"
          viewBox="0 0 24 24"
          fill="none"
        >
          
            id="toggle-path"
            stroke="currentColor"
            stroke-width="2"
            d="M15 19l-7-7 7-7"
          />
        
      
    
id="sidebar-nav" class="flex h-[calc(100vh-4rem)] flex-col justify-between px-4" > class="space-y-2" id="main-nav"> href="index.html" data-nav-link class="flex items-center rounded-lg px-4 py-2 text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700" title="Overview" > class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" > stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" /> class="ml-3" data-nav-label>Overview href="behavior.html" data-nav-link class="flex items-center rounded-lg px-4 py-2 text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700" title="Behavior Analysis" > class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" > stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" /> class="ml-3" data-nav-label>Behavior href="transactions.html" data-nav-link class="flex items-center rounded-lg px-4 py-2 text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700" title="Transaction History" > class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" > stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8h16M4 16h16" /> class="ml-3" data-nav-label>Transactions href="https://johnowolabiidogun.dev" data-nav-link class="flex items-center rounded-lg px-4 py-2 text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700" title="About Developer" target="_blank" > class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" > stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" /> class="ml-3" data-nav-label>About Developer
class="shrink-0"> class="mb-2 h-px w-full bg-gray-200 dark:bg-gray-700">