Published on

Advanced Guide: Build A Dashboard With Tailwind CSS

Tags
Dashboard

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of Dashboard ui component

Semoga bermanfaat untuk semua

Why use Tailwind CSS to build a Dashboard ui component?

  • It can make the building process of Dashboard ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Dashboard component file.

The preview of Dashboard ui component

Free download of the Dashboard's source code

The source code of Dashboard ui component

<!DOCTYPE html>
<html x-data="data()" lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Dashboard</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:[email protected];500;600;700;800&display=swap"
        rel="stylesheet" />
    <!-- Favicon -->
    <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
</head>

<body>
    <div class="flex h-screen bg-gray-800 " :class="{ 'overflow-hidden': isSideMenuOpen }">

        <!-- Desktop sidebar -->
        <aside class="z-20 flex-shrink-0 hidden w-60 pl-2 overflow-y-auto bg-gray-800 md:block">
            <div>
                <div class="text-white">
                    <div class="flex p-2  bg-gray-800">
                        <div class="flex py-3 px-2 items-center">
                            <p class="text-2xl text-green-500 font-semibold">SA</p <p class="ml-2 font-semibold italic">
                            DASHBOARD</p>
                        </div>
                    </div>
                    <div class="flex justify-center">
                        <div class="">
                            <img class="hidden h-24 w-24 rounded-full sm:block object-cover mr-2 border-4 border-green-400"
                                src="https://image.flaticon.com/icons/png/512/149/149071.png" alt="">
                            <p class="font-bold text-base  text-gray-400 pt-2 text-center w-24">Safwan</p>
                        </div>
                    </div>
                    <div>
                        <ul class="mt-6 leading-10">
                            <li class="relative px-2 py-1 ">
                                <a class="inline-flex items-center w-full text-sm font-semibold text-white transition-colors duration-150 cursor-pointer hover:text-green-500" 
                                    href=" #">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
                                        viewBox="0 0 24 24" stroke="currentColor">
                                        <path 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" />
                                    </svg>
                                    <span class="ml-4">DASHBOARD</span>
                                </a>
                            </li>
                            <li class="relative px-2 py-1" x-data="{ Open : false  }">
                                <div class="inline-flex items-center justify-between w-full text-base font-semibold transition-colors duration-150 text-gray-500  hover:text-yellow-400 cursor-pointer"
                                    x-on:click="Open = !Open">
                                    <span
                                        class="inline-flex items-center  text-sm font-semibold text-white hover:text-green-400">
                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
                                            viewBox="0 0 24 24" stroke="currentColor">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                                d="M8 4H6a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-2m-4-1v8m0 0l3-3m-3 3L9 8m-5 5h2.586a1 1 0 01.707.293l2.414 2.414a1 1 0 00.707.293h3.172a1 1 0 00.707-.293l2.414-2.414a1 1 0 01.707-.293H20" />
                                        </svg>
                                        <span class="ml-4">ITEM</span>
                                    </span>
                                    <svg xmlns="http://www.w3.org/2000/svg" x-show="!Open"
                                        class="ml-1  text-white w-4 h-4" fill="none" viewBox="0 0 24 24"
                                        stroke="currentColor" style="display: none;">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M15 19l-7-7 7-7" />
                                    </svg>

                                    <svg xmlns="http://www.w3.org/2000/svg" x-show="Open"
                                        class="ml-1  text-white w-4 h-4" fill="none" viewBox="0 0 24 24"
                                        stroke="currentColor" style="display: none;">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M19 9l-7 7-7-7" />
                                    </svg>
                                </div>

                                <div x-show.transition="Open" style="display:none;">
                                    <ul x-transition:enter="transition-all ease-in-out duration-300"
                                        x-transition:enter-start="opacity-25 max-h-0"
                                        x-transition:enter-end="opacity-100 max-h-xl"
                                        x-transition:leave="transition-all ease-in-out duration-300"
                                        x-transition:leave-start="opacity-100 max-h-xl"
                                        x-transition:leave-end="opacity-0 max-h-0"
                                        class="p-2 mt-2 space-y-2 overflow-hidden text-sm font-medium  rounded-md shadow-inner  bg-green-400"
                                        aria-label="submenu">

                                        <li class="px-2 py-1 text-white transition-colors duration-150">
                                            <div class="px-1 hover:text-gray-800 hover:bg-gray-100 rounded-md">
                                                <div class="flex items-center">
                                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none"
                                                        viewBox="0 0 24 24" stroke="currentColor">
                                                        <path 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" />
                                                    </svg>
                                                    <a href="#"
                                                        class="w-full ml-2  text-sm font-semibold text-white hover:text-gray-800">Item
                                                        1</a>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </aside>

        <!-- Mobile sidebar -->
        <!-- Backdrop -->
        <div x-show="isSideMenuOpen" x-transition:enter="transition ease-in-out duration-150"
            x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100"
            x-transition:leave="transition ease-in-out duration-150" x-transition:leave-start="opacity-100"
            x-transition:leave-end="opacity-0"
            class="fixed inset-0 z-10 flex items-end bg-black bg-opacity-50 sm:items-center sm:justify-center"></div>

        <aside
            class="fixed inset-y-0 z-20 flex-shrink-0 w-64 mt-16 overflow-y-auto  bg-gray-900 dark:bg-gray-800 md:hidden"
            x-show="isSideMenuOpen" x-transition:enter="transition ease-in-out duration-150"
            x-transition:enter-start="opacity-0 transform -translate-x-20" x-transition:enter-end="opacity-100"
            x-transition:leave="transition ease-in-out duration-150" x-transition:leave-start="opacity-100"
            x-transition:leave-end="opacity-0 transform -translate-x-20" @click.away="closeSideMenu"
            @keydown.escape="closeSideMenu">
            <div>
                <div class="text-white">
                    <div class="flex p-2  bg-gray-800">
                        <div class="flex py-3 px-2 items-center">
                            <p class="text-2xl text-green-500 font-semibold">SA</p <p class="ml-2 font-semibold italic">
                            DASHBOARD</p>
                        </div>
                    </div>
                    <div>
                        <ul class="mt-6 leading-10">
                            <li class="relative px-2 py-1 ">
                                <a class="inline-flex items-center w-full text-sm font-semibold text-white transition-colors duration-150 cursor-pointer hover:text-green-500"
                                    href=" #">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
                                        viewBox="0 0 24 24" stroke="currentColor">
                                        <path 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" />
                                    </svg>
                                    <span class="ml-4">DASHBOARD</span>
                                </a>
                            </li>
                            <li class="relative px-2 py-1" x-data="{ Open : false  }">
                                <div class="inline-flex items-center justify-between w-full text-base font-semibold transition-colors duration-150 text-gray-500  hover:text-yellow-400 cursor-pointer"
                                    x-on:click="Open = !Open">
                                    <span
                                        class="inline-flex items-center  text-sm font-semibold text-white hover:text-green-400">
                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
                                            viewBox="0 0 24 24" stroke="currentColor">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                                d="M8 4H6a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-2m-4-1v8m0 0l3-3m-3 3L9 8m-5 5h2.586a1 1 0 01.707.293l2.414 2.414a1 1 0 00.707.293h3.172a1 1 0 00.707-.293l2.414-2.414a1 1 0 01.707-.293H20" />
                                        </svg>
                                        <span class="ml-4">ITEM</span>
                                    </span>
                                    <svg xmlns="http://www.w3.org/2000/svg" x-show="!Open"
                                        class="ml-1  text-white w-4 h-4" fill="none" viewBox="0 0 24 24"
                                        stroke="currentColor" style="display: none;">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M15 19l-7-7 7-7" />
                                    </svg>

                                    <svg xmlns="http://www.w3.org/2000/svg" x-show="Open"
                                        class="ml-1  text-white w-4 h-4" fill="none" viewBox="0 0 24 24"
                                        stroke="currentColor" style="display: none;">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M19 9l-7 7-7-7" />
                                    </svg>
                                </div>

                                <div x-show.transition="Open" style="display:none;">
                                    <ul x-transition:enter="transition-all ease-in-out duration-300"
                                        x-transition:enter-start="opacity-25 max-h-0"
                                        x-transition:enter-end="opacity-100 max-h-xl"
                                        x-transition:leave="transition-all ease-in-out duration-300"
                                        x-transition:leave-start="opacity-100 max-h-xl"
                                        x-transition:leave-end="opacity-0 max-h-0"
                                        class="p-2 mt-2 space-y-2 overflow-hidden text-sm font-medium  rounded-md shadow-inner  bg-green-400"
                                        aria-label="submenu">

                                        <li class="px-2 py-1 text-white transition-colors duration-150">
                                            <div class="px-1 hover:text-gray-800 hover:bg-gray-100 rounded-md">
                                                <div class="flex items-center">
                                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none"
                                                        viewBox="0 0 24 24" stroke="currentColor">
                                                        <path 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" />
                                                    </svg>
                                                    <a href="#"
                                                        class="w-full ml-2  text-sm font-semibold text-white hover:text-gray-800">Item
                                                        1</a>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </aside>

        <div class="flex flex-col flex-1 w-full overflow-y-auto">
            <header class="z-40 py-4  bg-gray-800  ">
                <div class="flex items-center justify-between h-8 px-6 mx-auto">
                    <!-- Mobile hamburger -->
                    <button class="p-1 mr-5 -ml-1 rounded-md md:hidden focus:outline-none focus:shadow-outline-purple"
                        @click="toggleSideMenu" aria-label="Menu">
                        <x-heroicon-o-menu class="w-6 h-6 text-white" />
                        <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-white" fill="none"
                            viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                d="M4 6h16M4 12h16M4 18h7" />
                        </svg>
                    </button>

                    <!-- Search Input -->
                    <div class="flex justify-center  mt-2 mr-4">
                        <div class="relative flex w-full flex-wrap items-stretch mb-3">
                            <input type="search" placeholder="Search" {{ $attributes }}
                                class="form-input px-3 py-2 placeholder-gray-400 text-gray-700 relative bg-white rounded-lg text-sm shadow outline-none focus:outline-none focus:shadow-outline w-full pr-10" />
                            <span
                                class="z-10 h-full leading-snug font-normal  text-center text-gray-400 absolute bg-transparent rounded text-base items-center justify-center w-8 right-0 pr-3 py-3">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 -mt-1" fill="none"
                                    viewBox="0 0 24 24" stroke="currentColor">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                        d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                                </svg>
                            </span>
                        </div>
                    </div>

                    <ul class="flex items-center flex-shrink-0 space-x-6">

                        <!-- Notifications menu -->
                        <li class="relative">
                            <button
                                class="p-2 bg-white text-green-400 align-middle rounded-full hover:text-white hover:bg-green-400 focus:outline-none "
                                @click="toggleNotificationsMenu" @keydown.escape="closeNotificationsMenu"
                                aria-label="Notifications" aria-haspopup="true">
                                <div class="flex items-cemter">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
                                        viewBox="0 0 24 24" stroke="currentColor">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
                                    </svg>
                                </div>
                                <!-- Notification badge -->
                                <span aria-hidden="true"
                                    class="absolute top-0 right-0 inline-block w-3 h-3 transform translate-x-1 -translate-y-1 bg-red-600 border-2 border-white rounded-full dark:border-gray-800"></span>
                            </button>
                            <template x-if="isNotificationsMenuOpen">
                                <ul x-transition:leave="transition ease-in duration-150"
                                    x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0"
                                    @click.away="closeNotificationsMenu" @keydown.escape="closeNotificationsMenu"
                                    class="absolute right-0 w-56 p-2 mt-2 space-y-2 text-gray-600 bg-green-400 border border-green-500 rounded-md shadow-md">
                                    <li class="flex">
                                        <a class="text-white inline-flex items-center justify-between w-full px-2 py-1 text-sm font-semibold transition-colors duration-150 rounded-md hover:bg-gray-100 hover:text-gray-800"
                                            href="#">
                                            <span>Messages</span>
                                            <span
                                                class="inline-flex items-center justify-center px-2 py-1 text-xs font-bold leading-none text-red-600 bg-red-100 rounded-full dark:text-red-100 dark:bg-red-600">
                                                13
                                            </span>
                                        </a>
                                    </li>
                                </ul>
                            </template>
                        </li>

                        <!-- Profile menu -->
                        <li class="relative">
                            <button
                                class="p-2 bg-white text-green-400 align-middle rounded-full hover:text-white hover:bg-green-400 focus:outline-none "
                                @click="toggleProfileMenu" @keydown.escape="closeProfileMenu" aria-label="Account"
                                aria-haspopup="true">
                                <div class="flex items-center">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none"
                                        viewBox="0 0 24 24" stroke="currentColor">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                            d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
                                    </svg>
                                </div>
                            </button>
                            <template x-if="isProfileMenuOpen">
                                <ul x-transition:leave="transition ease-in duration-150"
                                    x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0"
                                    @click.away="closeProfileMenu" @keydown.escape="closeProfileMenu"
                                    class="absolute right-0 w-56 p-2 mt-2 space-y-2 text-gray-600 bg-green-400 border border-green-500 rounded-md shadow-md"
                                    aria-label="submenu">
                                    <li class="flex">
                                        <a class=" text-white inline-flex items-center w-full px-2 py-1 text-sm font-semibold transition-colors duration-150 rounded-md hover:bg-gray-100 hover:text-gray-800"
                                            href="#">
                                            <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 mr-2" fill="none"
                                                viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                                    d="M5.121 17.804A13.937 13.937 0 0112 16c2.5 0 4.847.655 6.879 1.804M15 10a3 3 0 11-6 0 3 3 0 016 0zm6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
                                            </svg>
                                            <span>Profile</span>
                                        </a>
                                    </li>
                                    <li class="flex">
                                        <a class="text-white inline-flex items-center w-full px-2 py-1 text-sm font-semibold transition-colors duration-150 rounded-md hover:bg-gray-100 hover:text-gray-800"
                                            href="#">
                                            <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 mr-2" fill="none"
                                                viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                                    d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
                                            </svg>
                                            <span>Log out</span>
                                        </a>
                                    </li>
                                </ul>
                            </template>
                        </li>
                    </ul>

                </div>
            </header>
            <main class="">
                <div class="grid mb-4 pb-10 px-8 mx-4 rounded-3xl bg-gray-100 border-4 border-green-400">

                    <div class="grid grid-cols-12 gap-6">
                        <div class="grid grid-cols-12 col-span-12 gap-6 xxl:col-span-9">
                            <div class="col-span-12 mt-8">
                                <div class="flex items-center h-10 intro-y">
                                    <h2 class="mr-5 text-lg font-medium truncate">Dashboard</h2>
                                </div>
                                <div class="grid grid-cols-12 gap-6 mt-5">
                                    <a class="transform  hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12 sm:col-span-6 xl:col-span-3 intro-y bg-white"
                                        href="#">
                                        <div class="p-5">
                                            <div class="flex justify-between">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 text-blue-400"
                                                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path stroke-linecap="round" stroke-linejoin="round"
                                                        stroke-width="2"
                                                        d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" />
                                                </svg>
                                                <div
                                                    class="bg-green-500 rounded-full h-6 px-2 flex justify-items-center text-white font-semibold text-sm">
                                                    <span class="flex items-center">30%</span>
                                                </div>
                                            </div>
                                            <div class="ml-2 w-full flex-1">
                                                <div>
                                                    <div class="mt-3 text-3xl font-bold leading-8">4.510</div>

                                                    <div class="mt-1 text-base text-gray-600">Item Sales</div>
                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                    <a class="transform  hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12 sm:col-span-6 xl:col-span-3 intro-y bg-white"
                                        href="#">
                                        <div class="p-5">
                                            <div class="flex justify-between">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 text-yellow-400"
                                                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path 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" />
                                                </svg>
                                                <div
                                                    class="bg-red-500 rounded-full h-6 px-2 flex justify-items-center text-white font-semibold text-sm">
                                                    <span class="flex items-center">30%</span>
                                                </div>
                                            </div>
                                            <div class="ml-2 w-full flex-1">
                                                <div>
                                                    <div class="mt-3 text-3xl font-bold leading-8">4.510</div>

                                                    <div class="mt-1 text-base text-gray-600">Item Sales</div>
                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                    <a class="transform  hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12 sm:col-span-6 xl:col-span-3 intro-y bg-white"
                                        href="#">
                                        <div class="p-5">
                                            <div class="flex justify-between">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 text-pink-600"
                                                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path stroke-linecap="round" stroke-linejoin="round"
                                                        stroke-width="2"
                                                        d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z" />
                                                    <path stroke-linecap="round" stroke-linejoin="round"
                                                        stroke-width="2"
                                                        d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z" />
                                                </svg>
                                                <div
                                                    class="bg-yellow-500 rounded-full h-6 px-2 flex justify-items-center text-white font-semibold text-sm">
                                                    <span class="flex items-center">30%</span>
                                                </div>
                                            </div>
                                            <div class="ml-2 w-full flex-1">
                                                <div>
                                                    <div class="mt-3 text-3xl font-bold leading-8">4.510</div>

                                                    <div class="mt-1 text-base text-gray-600">Item Sales</div>
                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                    <a class="transform  hover:scale-105 transition duration-300 shadow-xl rounded-lg col-span-12 sm:col-span-6 xl:col-span-3 intro-y bg-white"
                                        href="#">
                                        <div class="p-5">
                                            <div class="flex justify-between">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 text-green-400"
                                                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path stroke-linecap="round" stroke-linejoin="round"
                                                        stroke-width="2"
                                                        d="M7 12l3-3 3 3 4-4M8 21l4-4 4 4M3 4h18M4 4h16v12a1 1 0 01-1 1H5a1 1 0 01-1-1V4z" />
                                                </svg>
                                                <div
                                                    class="bg-blue-500 rounded-full h-6 px-2 flex justify-items-center text-white font-semibold text-sm">
                                                    <span class="flex items-center">30%</span>
                                                </div>
                                            </div>
                                            <div class="ml-2 w-full flex-1">
                                                <div>
                                                    <div class="mt-3 text-3xl font-bold leading-8">4.510</div>

                                                    <div class="mt-1 text-base text-gray-600">Item Sales</div>
                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                </div>
                            </div>
                            <div class="col-span-12 mt-5">
                                <div class="grid gap-2 grid-cols-1 lg:grid-cols-2">
                                    <div class="bg-white shadow-lg p-4" id="chartline"></div>
                                    <div class="bg-white shadow-lg" id="chartpie"></div>
                                </div>
                            </div>
                            <div class="col-span-12 mt-5">
                                <div class="grid gap-2 grid-cols-1 lg:grid-cols-1">
                                    <div class="bg-white p-4 shadow-lg rounded-lg">
                                        <h1 class="font-bold text-base">Table</h1>
                                        <div class="mt-4">
                                            <div class="flex flex-col">
                                                <div class="-my-2 overflow-x-auto">
                                                    <div class="py-2 align-middle inline-block min-w-full">
                                                        <div
                                                            class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg bg-white">
                                                            <table class="min-w-full divide-y divide-gray-200">
                                                                <thead>
                                                                    <tr>
                                                                        <th
                                                                            class="px-6 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
                                                                            <div class="flex cursor-pointer">
                                                                                <span class="mr-2">PRODUCT NAME</span>
                                                                            </div>
                                                                        </th>
                                                                        <th
                                                                            class="px-6 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
                                                                            <div class="flex cursor-pointer">
                                                                                <span class="mr-2">Stock</span>
                                                                            </div>
                                                                        </th>
                                                                        <th
                                                                            class="px-6 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
                                                                            <div class="flex cursor-pointer">
                                                                                <span class="mr-2">STATUS</span>
                                                                            </div>
                                                                        </th>
                                                                        <th
                                                                            class="px-6 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
                                                                            <div class="flex cursor-pointer">
                                                                                <span class="mr-2">ACTION</span>
                                                                            </div>
                                                                        </th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody class="bg-white divide-y divide-gray-200">
                                                                    <tr>
                                                                        <td
                                                                            class="px-6 py-4 whitespace-no-wrap text-sm leading-5">
                                                                            <p>Apple MacBook Pro 13</p>
                                                                            <p class="text-xs text-gray-400">PC & Laptop
                                                                            </p>
                                                                        </td>
                                                                        <td
                                                                            class="px-6 py-4 whitespace-no-wrap text-sm leading-5">
                                                                            <p>77</p>
                                                                        </td>
                                                                        <td
                                                                            class="px-6 py-4 whitespace-no-wrap text-sm leading-5">
                                                                            <div class="flex text-green-500">
                                                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                                                    class="w-5 h-5 mr-1" fill="none"
                                                                                    viewBox="0 0 24 24"
                                                                                    stroke="currentColor">
                                                                                    <path stroke-linecap="round"
                                                                                        stroke-linejoin="round"
                                                                                        stroke-width="2"
                                                                                        d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
                                                                                </svg>
                                                                                <p>Active</p>
                                                                            </div>
                                                                        </td>
                                                                        <td
                                                                            class="px-6 py-4 whitespace-no-wrap text-sm leading-5">
                                                                            <div class="flex space-x-4">
                                                                                <a href="#" class="text-blue-500 hover:text-blue-600">
                                                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                                                    class="w-5 h-5 mr-1"
                                                                                    fill="none" viewBox="0 0 24 24"
                                                                                    stroke="currentColor">
                                                                                    <path stroke-linecap="round"
                                                                                        stroke-linejoin="round"
                                                                                        stroke-width="2"
                                                                                        d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                                                                                </svg>
                                                                                <p>Edit</p>
                                                                                </a>
                                                                                <a href="#" class="text-red-500 hover:text-red-600">
                                                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                                                    class="w-5 h-5 mr-1 ml-3"
                                                                                    fill="none" viewBox="0 0 24 24"
                                                                                    stroke="currentColor">
                                                                                    <path stroke-linecap="round"
                                                                                        stroke-linejoin="round"
                                                                                        stroke-width="2"
                                                                                        d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
                                                                                </svg>
                                                                                <p>Delete</p>
                                                                                </a>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
    <script>
        function data() {
          
            return {
               
                isSideMenuOpen: false,
                toggleSideMenu() {
                    this.isSideMenuOpen = !this.isSideMenuOpen
                },
                closeSideMenu() {
                    this.isSideMenuOpen = false
                },
                isNotificationsMenuOpen: false,
                toggleNotificationsMenu() {
                    this.isNotificationsMenuOpen = !this.isNotificationsMenuOpen
                },
                closeNotificationsMenu() {
                    this.isNotificationsMenuOpen = false
                },
                isProfileMenuOpen: false,
                toggleProfileMenu() {
                    this.isProfileMenuOpen = !this.isProfileMenuOpen
                },
                closeProfileMenu() {
                    this.isProfileMenuOpen = false
                },
                isPagesMenuOpen: false,
                togglePagesMenu() {
                    this.isPagesMenuOpen = !this.isPagesMenuOpen
                },
               
            }
        }
    </script>
    <script>
        var chart = document.querySelector('#chartline')
        var options = {
            series: [{
                name: 'TEAM A',
                type: 'area',
                data: [44, 55, 31, 47, 31, 43, 26, 41, 31, 47, 33]
            }, {
                name: 'TEAM B',
                type: 'line',
                data: [55, 69, 45, 61, 43, 54, 37, 52, 44, 61, 43]
            }],
            chart: {
                height: 350,
                type: 'line',
                zoom: {
                    enabled: false
                }
            },
            stroke: {
                curve: 'smooth'
            },
            fill: {
                type: 'solid',
                opacity: [0.35, 1],
            },
            labels: ['Dec 01', 'Dec 02', 'Dec 03', 'Dec 04', 'Dec 05', 'Dec 06', 'Dec 07', 'Dec 08', 'Dec 09 ',
                'Dec 10', 'Dec 11'
            ],
            markers: {
                size: 0
            },
            yaxis: [{
                    title: {
                        text: 'Series A',
                    },
                },
                {
                    opposite: true,
                    title: {
                        text: 'Series B',
                    },
                },
            ],
            tooltip: {
                shared: true,
                intersect: false,
                y: {
                    formatter: function(y) {
                        if (typeof y !== "undefined") {
                            return y.toFixed(0) + " points";
                        }
                        return y;
                    }
                }
            }
        };
        var chart = new ApexCharts(chart, options);
        chart.render();
    </script>
    <script>
        var chart = document.querySelector('#chartpie')
        var options = {
            series: [44, 55, 67, 83],
            chart: {
                height: 350,
                type: 'radialBar',
            },
            plotOptions: {
                radialBar: {
                    dataLabels: {
                        name: {
                            fontSize: '22px',
                        },
                        value: {
                            fontSize: '16px',
                        },
                        total: {
                            show: true,
                            label: 'Total',
                            formatter: function(w) {
                                // By default this function returns the average of all series. The below is just an example to show the use of custom formatter function
                                return 249
                            }
                        }
                    }
                }
            },
            labels: ['Apples', 'Oranges', 'Bananas', 'Berries'],
        };
        var chart = new ApexCharts(chart, options);
        chart.render();
    </script>
</body>

</html>

How to build a Dashboard with Tailwind CSS?

Install tailwind css of verion 2.0.3

Use the script html tag to import the script of Tailwind CSS of the version 2.0.3

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to build a Dashboard component

  • flex
  • h-screen
  • bg-gray-800
  • overflow-hidden
  • z-20
  • flex-shrink-0
  • hidden
  • w-60
  • pl-2
  • overflow-y-auto
  • md:block
  • text-white
  • p-2
  • py-3
  • px-2
  • text-2xl
  • text-green-500
  • ml-2
  • h-24
  • w-24
  • sm:block
  • mr-2
  • border-4
  • border-green-400
  • text-base
  • text-gray-400
  • pt-2
  • text-center
  • mt-6
  • relative
  • py-1
  • inline-flex
  • w-full
  • text-sm
  • hover:text-green-500
  • h-6
  • w-6
  • ml-4
  • text-gray-500
  • hover:text-yellow-400
  • hover:text-green-400
  • ml-1
  • w-4
  • h-4
  • mt-2
  • bg-green-400
  • px-1
  • hover:text-gray-800
  • hover:bg-gray-100
  • h-5
  • w-5
  • fixed
  • z-10
  • bg-black
  • bg-opacity-50
  • w-64
  • mt-16
  • bg-gray-900
  • dark:bg-gray-800
  • md:hidden
  • flex-col
  • flex-1
  • z-40
  • py-4
  • h-8
  • px-6
  • mx-auto
  • p-1
  • mr-5
  • -ml-1
  • mr-4
  • flex-wrap
  • mb-3
  • px-3
  • py-2
  • text-gray-700
  • bg-white
  • pr-10
  • h-full
  • absolute
  • bg-transparent
  • w-8
  • right-0
  • pr-3
  • -mt-1
  • text-green-400
  • hover:text-white
  • hover:bg-green-400
  • top-0
  • inline-block
  • w-3
  • h-3
  • bg-red-600
  • border-2
  • border-white
  • dark:border-gray-800
  • w-56
  • text-gray-600
  • border-green-500
  • text-xs
  • text-red-600
  • bg-red-100
  • dark:text-red-100
  • dark:bg-red-600
  • grid
  • mb-4
  • pb-10
  • px-8
  • mx-4
  • bg-gray-100
  • grid-cols-12
  • gap-6
  • mt-8
  • h-10
  • text-lg
  • mt-5
  • p-5
  • h-7
  • w-7
  • text-blue-400
  • bg-green-500
  • mt-3
  • text-3xl
  • mt-1
  • text-yellow-400
  • bg-red-500
  • text-pink-600
  • bg-yellow-500
  • bg-blue-500
  • gap-2
  • grid-cols-1
  • lg:grid-cols-2
  • p-4
  • lg:grid-cols-1
  • mt-4
  • -my-2
  • overflow-x-auto
  • min-w-full
  • border-b
  • border-gray-200
  • bg-gray-50
  • mr-1
  • text-blue-500
  • hover:text-blue-600
  • text-red-500
  • hover:text-red-600
  • ml-3

147 steps to build a Dashboard component with Tailwind CSS

  1. Use flex to create a block-level flex container.

  2. Use h-screen to make an element span the entire height of the viewport.

  3. Control the background color of an element to gray-800 using the bg-gray-800 utilities.

  4. Use overflow-hidden to clip any content within an element that overflows the bounds of that element.

  5. Control the stack order (or three-dimensional positioning) of an element to 20 in Tailwind, regardless of order it has been displayed, using the z-20 utilities.

  6. Use flex to create a block-level flex container.

  7. Use hidden to set an element to display: none and remove it from the page layout.

  8. Use w-60 to set an element to a fixed width(15rem).

  9. Set the left padding of the element to 0.5rem using the pl-2 utilities class

  10. Use overflow-y-auto to allow vertical scrolling if needed.

  11. Use inline utilities to put the element on its own line and fill its parent at only medium screen sizes.

  12. Control the text color of an element to white using the text-white utilities.

  13. Control the padding on all sides of an element to 0.5rem using the p-2 utilities.

  14. Control the vertical padding of an element to 0.75rem using the py-3 utilities.

  15. Control the horizontal padding of an element to 0.5rem using the px-2 utilities.

  16. Control the text color of an element to 2xl using the text-2xl utilities.

  17. Control the text color of an element to green-500 using the text-green-500 utilities.

  18. Control the margin on left side of an element to 0.5rem using the ml-2 utilities.

  19. Use h-24 to set an element to a fixed height(6rem).

  20. Use w-24 to set an element to a fixed width(6rem).

  21. Use inline utilities to put the element on its own line and fill its parent at only small screen sizes.

  22. Control the margin on right side of an element to 0.5rem using the mr-2 utilities.

  23. Control the border color of an element to 1rem using the border-4 utilities.

  24. Control the border color of an element to green-400 using the border-green-400 utilities.

  25. Control the text color of an element to base using the text-base utilities.

  26. Control the text color of an element to gray-400 using the text-gray-400 utilities.

  27. Control the padding on top side of an element to 0.5rem using the pt-2 utilities.

  28. Control the text color of an element to center using the text-center utilities.

  29. Control the margin on top side of an element to 1.5rem using the mt-6 utilities.

  30. Use relative to position an element according to the normal flow of the document.

  31. Control the vertical padding of an element to 0.25rem using the py-1 utilities.

  32. Use inline-flex to create an inline flex container that flows with text.

  33. Use w-full to set an element to a 100% based width.

  34. Control the text color of an element to sm using the text-sm utilities.

  35. Control the text color of an element to green-500 on hover using the hover:text-green-500 utilities.

  36. Use h-6 to set an element to a fixed height(1.5rem).

  37. Use w-6 to set an element to a fixed width(1.5rem).

  38. Control the margin on left side of an element to 1rem using the ml-4 utilities.

  39. Control the text color of an element to gray-500 using the text-gray-500 utilities.

  40. Control the text color of an element to yellow-400 on hover using the hover:text-yellow-400 utilities.

  41. Control the text color of an element to green-400 on hover using the hover:text-green-400 utilities.

  42. Control the margin on left side of an element to 0.25rem using the ml-1 utilities.

  43. Use w-4 to set an element to a fixed width(1rem).

  44. Use h-4 to set an element to a fixed height(1rem).

  45. Control the margin on top side of an element to 0.5rem using the mt-2 utilities.

  46. Control the background color of an element to green-400 using the bg-green-400 utilities.

  47. Control the horizontal padding of an element to 0.25rem using the px-1 utilities.

  48. Control the text color of an element to gray-800 on hover using the hover:text-gray-800 utilities.

  49. Control the background color of an element to gray-100 using the hover:bg-gray-100 utilities on hover.

  50. Use h-5 to set an element to a fixed height(1.25rem).

  51. Use w-5 to set an element to a fixed width(1.25rem).

  52. Use fixed to position an element relative to the browser window.

  53. Control the stack order (or three-dimensional positioning) of an element to 10 in Tailwind, regardless of order it has been displayed, using the z-10 utilities.

  54. Control the background color of an element to black using the bg-black utilities.

  55. Control the background color of an element to opacity-50 using the bg-opacity-50 utilities.

  56. Use w-64 to set an element to a fixed width(16rem).

  57. Control the margin on top side of an element to 4rem using the mt-16 utilities.

  58. Control the background color of an element to gray-900 using the bg-gray-900 utilities.

  59. Control the background color of an element to gray-800 using the dark:bg-gray-800 utilities in dark theme.

  60. Use hidden to set an element to display: none and remove it from the page layout at only medium screen sizes.

  61. Use flex to create a block-level flex container.

  62. Use flex to create a block-level flex container.

  63. Control the stack order (or three-dimensional positioning) of an element to 40 in Tailwind, regardless of order it has been displayed, using the z-40 utilities.

  64. Control the vertical padding of an element to 1rem using the py-4 utilities.

  65. Use h-8 to set an element to a fixed height(2rem).

  66. Control the horizontal padding of an element to 1.5rem using the px-6 utilities.

  67. Control the horizontal margin of an element to auto using the mx-auto utilities.

  68. Control the padding on all sides of an element to 0.25rem using the p-1 utilities.

  69. Control the margin on right side of an element to 1.25rem using the mr-5 utilities.

  70. Control the margin on left side of an element to -0.25rem using the -ml-1 utilities.

  71. Control the margin on right side of an element to 1rem using the mr-4 utilities.

  72. Use flex to create a block-level flex container.

  73. Control the margin on bottom side of an element to 0.75rem using the mb-3 utilities.

  74. Control the horizontal padding of an element to 0.75rem using the px-3 utilities.

  75. Control the vertical padding of an element to 0.5rem using the py-2 utilities.

  76. Control the text color of an element to gray-700 using the text-gray-700 utilities.

  77. Control the background color of an element to white using the bg-white utilities.

  78. Control the padding on right side of an element to 2.5rem using the pr-10 utilities.

  79. Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

  80. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  81. Control the background color of an element to transparent using the bg-transparent utilities.

  82. Use w-8 to set an element to a fixed width(2rem).

  83. Use the right-0 utilities to set the right position of a positioned element to 0rem.

  84. Control the padding on right side of an element to 0.75rem using the pr-3 utilities.

  85. Control the margin on top side of an element to -0.25rem using the -mt-1 utilities.

  86. Control the text color of an element to green-400 using the text-green-400 utilities.

  87. Control the text color of an element to white on hover using the hover:text-white utilities.

  88. Control the background color of an element to green-400 using the hover:bg-green-400 utilities on hover.

  89. Use the top-0 utilities to set the top position of a positioned element to 0rem.

  90. Use inline-block utilities to wrap the element to prevent the text inside from extending beyond its parent.

  91. Use w-3 to set an element to a fixed width(0.75rem).

  92. Use h-3 to set an element to a fixed height(0.75rem).

  93. Control the background color of an element to red-600 using the bg-red-600 utilities.

  94. Control the border color of an element to 0.5rem using the border-2 utilities.

  95. Control the border color of an element to white using the border-white utilities.

  96. Control the border color of an element to gray-800 using the dark:border-gray-800 utilities in dark theme.

  97. Use w-56 to set an element to a fixed width(14rem).

  98. Control the text color of an element to gray-600 using the text-gray-600 utilities.

  99. Control the border color of an element to green-500 using the border-green-500 utilities.

  100. Control the text color of an element to xs using the text-xs utilities.

  101. Control the text color of an element to red-600 using the text-red-600 utilities.

  102. Control the background color of an element to red-100 using the bg-red-100 utilities.

  103. Control the text color of an element to red-100 in dark theme using the dark:text-red-100 utilities.

  104. Control the background color of an element to red-600 using the dark:bg-red-600 utilities in dark theme.

  105. Use grid to create a grid container.

  106. Control the margin on bottom side of an element to 1rem using the mb-4 utilities.

  107. Control the padding on bottom side of an element to 2.5rem using the pb-10 utilities.

  108. Control the horizontal padding of an element to 2rem using the px-8 utilities.

  109. Control the horizontal margin of an element to 1rem using the mx-4 utilities.

  110. Control the background color of an element to gray-100 using the bg-gray-100 utilities.

  111. Use grid to create a grid container.

  112. To specify the width between columns, you can use the gap-6 utilities.

  113. Control the margin on top side of an element to 2rem using the mt-8 utilities.

  114. Use h-10 to set an element to a fixed height(2.5rem).

  115. Control the text color of an element to lg using the text-lg utilities.

  116. Control the margin on top side of an element to 1.25rem using the mt-5 utilities.

  117. Control the padding on all sides of an element to 1.25rem using the p-5 utilities.

  118. Use h-7 to set an element to a fixed height(1.75rem).

  119. Use w-7 to set an element to a fixed width(1.75rem).

  120. Control the text color of an element to blue-400 using the text-blue-400 utilities.

  121. Control the background color of an element to green-500 using the bg-green-500 utilities.

  122. Control the margin on top side of an element to 0.75rem using the mt-3 utilities.

  123. Control the text color of an element to 3xl using the text-3xl utilities.

  124. Control the margin on top side of an element to 0.25rem using the mt-1 utilities.

  125. Control the text color of an element to yellow-400 using the text-yellow-400 utilities.

  126. Control the background color of an element to red-500 using the bg-red-500 utilities.

  127. Control the text color of an element to pink-600 using the text-pink-600 utilities.

  128. Control the background color of an element to yellow-500 using the bg-yellow-500 utilities.

  129. Control the background color of an element to blue-500 using the bg-blue-500 utilities.

  130. To specify the width between columns, you can use the gap-2 utilities.

  131. Use grid to create a grid container.

  132. Use grid to create a grid container at only large screen sizes.

  133. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  134. Use grid to create a grid container at only large screen sizes.

  135. Control the margin on top side of an element to 1rem using the mt-4 utilities.

  136. Control the vertical margin of an element to -0.5rem using the -my-2 utilities.

  137. Use overflow-x-auto to allow horizontal scrolling if needed.

  138. Set the minimum width/height of an element using the min-w-full utilities.

  139. Control the border color of an element to b using the border-b utilities.

  140. Control the border color of an element to gray-200 using the border-gray-200 utilities.

  141. Control the background color of an element to gray-50 using the bg-gray-50 utilities.

  142. Control the margin on right side of an element to 0.25rem using the mr-1 utilities.

  143. Control the text color of an element to blue-500 using the text-blue-500 utilities.

  144. Control the text color of an element to blue-600 on hover using the hover:text-blue-600 utilities.

  145. Control the text color of an element to red-500 using the text-red-500 utilities.

  146. Control the text color of an element to red-600 on hover using the hover:text-red-600 utilities.

  147. Control the margin on left side of an element to 0.75rem using the ml-3 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to build a Dashboard components, learn and follow along to implement your own components.