Published on

Advanced Guide: Make A Dashboard (Not Yet!!!) With Tailwind CSS

Tags
Dashboard (Not Yet!!!)

As a FrontEnd technology blogger, you must have heard about Tailwind CSS. It's a utility-first CSS framework that helps you quickly build custom designs. In this article, we will explore how to use Tailwind CSS to create a Dashboard (Not Yet!!!) UI component.

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that provides a set of pre-defined CSS classes that you can use to style your HTML elements. With Tailwind CSS, you don't need to write custom CSS code for every element. Instead, you can use the pre-defined classes to style your elements.

The description of Dashboard (Not Yet!!!) UI component

A dashboard is a user interface that displays important information and metrics in a visual format. It's a great way to quickly get an overview of your data. In this tutorial, we will create a Dashboard (Not Yet!!!) UI component that displays some sample data.

Why use Tailwind CSS to create a Dashboard (Not Yet!!!) UI component?

Tailwind CSS provides a set of pre-defined CSS classes that you can use to style your elements. This makes it easier to create custom designs without writing custom CSS code. Additionally, Tailwind CSS is highly customizable, which means you can easily modify the default styles to match your design requirements.

The preview of Dashboard (Not Yet!!!) UI component

In this section, we will provide a preview of the Dashboard (Not Yet!!!) UI component. The component will display some sample data in a visually appealing format.

Free download of the Dashboard (Not Yet!!!)'s source code

The source code of Dashboard (Not Yet!!!) UI component

In this section, we will provide the source code for the Dashboard (Not Yet!!!) UI component. The code will include HTML and CSS code that you can use to create the component.

<div class="min-h-screen flex">
  <div class="py-12 px-10 w-1/4">
    <div class="flex space-2 items-center border-b-2 pb-4">
      <div>
        <svg xmlns="http://www.w3.org/2000/svg" class="h-14 w-14 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
        </svg>
      </div>
      <div class="ml-3">
        <h1 class="text-3xl font-bold text-indigo-600">VENUS</h1>
        <p class="text-center text-sm text-indigo-600 mt-1 font-serif">DASHBOARD</p>
      </div>
    </div>
    <div class="flex items-center space-x-4 mt-6 p-2 bg-indigo-600 rounded-md">
      <div>
        <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z" />
        </svg>
      </div>
      <div>
        <p class="text-lg text-white font-semibold">Dashboard</p>
      </div>
    </div>
    <div class="mt-8">
      <ul class="space-y-10">
        <li>
          <a href="#" class="flex items-center text-sm font-semibold text-gray-500 hover:text-indigo-600 transition duration-200">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-4 text-gray-400 hover:text-indigo-600 transition duration-200" viewBox="0 0 20 20" fill="currentColor">
              <path d="M2 11a1 1 0 011-1h2a1 1 0 011 1v5a1 1 0 01-1 1H3a1 1 0 01-1-1v-5zM8 7a1 1 0 011-1h2a1 1 0 011 1v9a1 1 0 01-1 1H9a1 1 0 01-1-1V7zM14 4a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1h-2a1 1 0 01-1-1V4z" />
            </svg>
            Activity</a
          >
        </li>
        <li>
          <a href="#" class="flex items-center text-sm font-semibold text-gray-500 hover:text-indigo-600 transition duration-200" hover:text-indigo-600>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-4 text-gray-400 hover:text-indigo-600 transition duration-200" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
            </svg>
            Library</a
          >
        </li>
        <li>
          <a href="#" class="flex items-center text-sm font-semibold text-gray-500 hover:text-indigo-600 transition duration-200" hover:text-indigo-600>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-4 text-gray-400 hover:text-indigo-600 transition duration-200" viewBox="0 0 20 20" fill="currentColor">
              <path fill-rule="evenodd" d="M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
            </svg>
            Security</a
          >
        </li>
        <li>
          <a href="#" class="flex items-center text-sm font-semibold text-gray-500 hover:text-indigo-600 transition duration-200" hover:text-indigo-600>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-4 text-gray-400 hover:text-indigo-600 transition duration-200" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
            </svg>
            Schedules</a
          >
        </li>
        <li>
          <a href="#" class="flex items-centerx text-sm font-semibold text-gray-500 hover:text-indigo-600 transition duration-200">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-4 text-gray-400 hover:text-indigo-600 transition duration-200" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
            </svg>
            Payouts</a
          >
        </li>
        <li>
          <a href="#" class="flex items-center text-sm font-semibold text-gray-500 hover:text-indigo-600 transition duration-200" hover:text-indigo-600>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-4 text-gray-400 hover:text-indigo-600 transition duration-200" 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>
            Settings</a
          >
        </li>
      </ul>
    </div>
    <div class="flex mt-20 space-x-4 items-center">
      <div>
        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-400 hover:text-indigo-600 transition duration-200" 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>
      </div>
      <a href="#" class="block font-semibold text-gray-500 hover:text-indigo-600 transition duration-200">Logout</a>
    </div>
  </div>
  <div class="bg-indigo-50 flex-grow py-12 px-10">
    <div class="flex justify-between">
      <div>
        <h4 class="text-sm font-bold text-indigo-600">Hi Andrei,</h4>
        <h1 class="text-4xl font-bold text-indigo-900 mt-">Welcome to Venus!</h1>
      </div>
      <div>
        <div class="flex items-center border rounded-lg bg-white w-max py-2 px-4 space-x-3">
          <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" 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>
          <input class="outline-none" type="text" placeholder="Search" />
        </div>
      </div>
    </div>
    <div>
      <div class="flex space-x-4">
        <div class="flex items-center justify-around p-6 bg-white w-64 rounded-xl space-x-2 mt-10 shadow-lg">
          <div>
            <span class="text-sm font-semibold text-gray-400">Spent this month</span>
            <h1 class="text-2xl font-bold">$682.5</h1>
          </div>
          <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 11l7-7 7 7M5 19l7-7 7 7" />
            </svg>
          </div>
        </div>
        <div class="flex items-center justify-around p-6 bg-white w-64 rounded-xl space-x-2 mt-10 shadow-lg">
          <div>
            <span class="text-sm font-semibold text-gray-400">Spent this month</span>
            <h1 class="text-2xl font-bold">$682.5</h1>
          </div>
          <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-indigo-600" viewBox="0 0 20 20" fill="currentColor">
              <path d="M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3zM6 8a2 2 0 11-4 0 2 2 0 014 0zM16 18v-3a5.972 5.972 0 00-.75-2.906A3.005 3.005 0 0119 15v3h-3zM4.75 12.094A5.973 5.973 0 004 15v3H1v-3a3 3 0 013.75-2.906z" />
            </svg>
          </div>
        </div>
        <div class="flex items-center justify-around p-6 bg-white w-64 rounded-xl space-x-2 mt-10 shadow-lg">
          <div>
            <span class="text-sm font-semibold text-gray-400">Spent this month</span>
            <h1 class="text-2xl font-bold">$682.5</h1>
          </div>
          <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 13v-1m4 1v-3m4 3V8M8 21l4-4 4 4M3 4h18M4 4h16v12a1 1 0 01-1 1H5a1 1 0 01-1-1V4z" />
            </svg>
          </div>
        </div>
        <div class="flex items-center justify-around p-6 bg-white w-64 rounded-xl space-x-2 mt-10 shadow-lg">
          <div>
            <span class="text-sm font-semibold text-gray-400">Spent this month</span>
            <h1 class="text-2xl font-bold">$682.5</h1>
          </div>
          <div>
            <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-indigo-600" viewBox="0 0 20 20" fill="currentColor">
              <path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" />
            </svg>
          </div>
        </div>
      </div>
      <div class="flex mt-10 justify-center">
        <div>
          <table class="min-w-full table-auto">
            <thead class="justify-between">
              <tr class="bg-indigo-600">
                <th class="px-16 py-2">
                  <span class="text-gray-300"></span>
                </th>
                <th class="px-16 py-2">
                  <span class="text-indigo-50">Img</span>
                </th>
                <th class="px-16 py-2">
                  <span class="text-indigo-50">Name</span>
                </th>
                <th class="px-16 py-2">
                  <span class="text-indigo-50">Barcode</span>
                </th>

                <th class="px-16 py-2">
                  <span class="text-indigo-50">Price</span>
                </th>
                <th class="px-16 py-2">
                  <span class="text-indigo-50">Status</span>
                </th>
              </tr>
            </thead>
            <tbody class="bg-gray-200">
              <tr class="bg-white border-4 border-gray-200 text-center">
                <td class="px-16 py-2 flex flex-row items-center">
                  <img class="h-8 w-8 object-cover" src="https://randomuser.me/api/portraits/men/30.jpg" alt="" />
                </td>
                <td>
                  <span class="text-center ml-2 font-semibold">Dean Lynch</span>
                </td>
                <td class="px-16 py-2">samsung</td>
                <td class="px-16 py-2">
                  <span>05/06/2020</span>
                </td>
                <td class="px-16 py-2">
                  <span>10:00</span>
                </td>

                <td class="px-16 py-2">
                  <span class="text-green-500">
                    <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h5" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
                      <path stroke="none" d="M0 0h24v24H0z" />
                      <path d="M5 12l5 5l10 -10" />
                    </svg>
                  </span>
                </td>
              </tr>
              <tr class="bg-white border-4 border-gray-200 text-center">
                <td class="px-16 py-2 flex flex-row items-center">
                  <img class="h-8 w-8 object-cover" src="https://randomuser.me/api/portraits/men/76.jpg" alt="" />
                </td>
                <td>
                  <span class="text-center ml-2 font-semibold">Ralph Barnes</span>
                </td>
                <td class="px-16 py-2">Iphone 13</td>
                <td class="px-16 py-2">
                  <span>05/06/2020</span>
                </td>
                <td class="px-16 py-2">
                  <span>12:15</span>
                </td>

                <td class="px-16 py-2">
                  <span class="text-yellow-500">
                    <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
                      <path stroke="none" d="M0 0h24v24H0z" />
                      <circle cx="12" cy="12" r="9" />
                      <polyline points="12 7 12 12 15 15" />
                    </svg>
                  </span>
                </td>
              </tr>
              <tr class="bg-white border-4 border-gray-200 text-center">
                <td class="px-16 py-2 flex flex-row items-center">
                  <img class="h-8 w-8 object-cover" src="https://randomuser.me/api/portraits/men/38.jpg" alt="" />
                </td>
                <td>
                  <span class="text-center ml-2 font-semibold">Brett Castillo</span>
                </td>
                <td class="px-16 py-2">Oppo mini</td>
                <td class="px-16 py-2">
                  <span>05/06/2020</span>
                </td>
                <td class="px-16 py-2">
                  <span>08:35</span>
                </td>

                <td class="px-16 py-2">
                  <span class="text-yellow-500">
                    <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
                      <path stroke="none" d="M0 0h24v24H0z" />
                      <line x1="18" y1="6" x2="6" y2="18" />
                      <line x1="6" y1="6" x2="18" y2="18" />
                    </svg>
                  </span>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div></div>
      <div></div>
    </div>
    <div></div>
    <div></div>
  </div>
</div>

How to create a Dashboard (Not Yet!!!) with Tailwind CSS?

Now that we have a basic understanding of Tailwind CSS and the Dashboard (Not Yet!!!) UI component, let's see how we can create the component using Tailwind CSS.

  1. Create a new HTML file and add the following code:
<div class="bg-white rounded-lg shadow-lg p-6">
  <h2 class="text-lg font-medium text-gray-900 mb-4">Dashboard (Not Yet!!!)</h2>
  <div class="grid grid-cols-2 gap-4">
    <div class="bg-blue-500 rounded-lg p-4">
      <h3 class="text-lg font-medium text-white mb-2">Metric 1</h3>
      <p class="text-gray-200">1000</p>
    </div>
    <div class="bg-green-500 rounded-lg p-4">
      <h3 class="text-lg font-medium text-white mb-2">Metric 2</h3>
      <p class="text-gray-200">2000</p>
    </div>
  </div>
</div>
  1. Save the file and open it in your browser. You should see the Dashboard (Not Yet!!!) UI component displayed on the screen.

Let's break down the code and see how it works.

First, we create a div element with the bg-white, rounded-lg, shadow-lg, and p-6 classes. These classes add a white background, rounded corners, a drop shadow, and some padding to the element.

Next, we add a h2 element with the text-lg, font-medium, text-gray-900, and mb-4 classes. These classes add a large font size, bold text, a dark gray color, and some margin to the element.

Inside the div element, we add a div element with the grid and grid-cols-2 classes. These classes create a two-column grid layout.

Inside the grid, we add two div elements with the bg-blue-500 and bg-green-500 classes. These classes add a blue and green background color to the elements.

Inside each div element, we add a h3 element with the text-lg, font-medium, text-white, and mb-2 classes. These classes add a large font size, bold text, a white color, and some margin to the element.

Finally, we add a p element with the text-gray-200 class. This class adds a light gray color to the text.

And that's it! We have created a Dashboard (Not Yet!!!) UI component using Tailwind CSS.

Conclusion

In this article, we explored how to use Tailwind CSS to create a Dashboard (Not Yet!!!) UI component. We learned about Tailwind CSS, the Dashboard (Not Yet!!!) UI component, and how to create the component using HTML and Tailwind CSS classes. With Tailwind CSS, you can quickly create custom designs without writing custom CSS code.