- Published on
How to Build A Card Dashboard With Tailwind CSS?

- What is Tailwind CSS?
- The description of Card Dashboard ui component
- Why use Tailwind CSS to build a Card Dashboard ui component?
- The preview of Card Dashboard ui component
- The source code of Card Dashboard ui component
- How to build a Card Dashboard with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to build a Card Dashboard component
- 73 steps to build a Card Dashboard component with Tailwind CSS
- Conclusion
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 Card Dashboard ui component
Semoga bermanfaat untuk semua
Why use Tailwind CSS to build a Card Dashboard ui component?
- It can make the building process of Card Dashboard ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Card Dashboard component file.
The preview of Card Dashboard ui component
Free download of the Card Dashboard's source code
The source code of Card Dashboard ui component
<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" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
</head>
<body>
<div class="h-full bg-gradient-to-r from-pink-300 to-indigo-300">
<div class="grid grid-cols-12 gap-0">
<div class="col-span-12 sm:col-span-12 md:col-span-12 lg:col-span-8 xxl:col-span-8 px-6 py-6">
<div class="grid grid-cols-12 gap-6">
<div class="col-span-12 sm:col-span-12 md:col-span-6 lg:col-span-6 xxl:col-span-6">
<!-- Start Nav Bar -->
<nav x-data="{ active: 1 }" class="bg-white p-4 rounded-xl shadow-xl flex items-center">
<a href="#" class="flex space-x-2 items-center mr-4 text-gray-400"
x-bind:class="{'text-indigo-600 border-b-4 border-indigo-600': active === 1 }"
x-on:click.prevent="active = 1">
<i class="fas fa-columns fa-lg"></i>
<p class="font-semibold text-sm">Dashboard</p>
</a>
<a href="#" class="flex space-x-2 items-center mr-4 text-gray-400"
x-bind:class="{'text-indigo-600 border-b-4 border-indigo-600': active === 2 }"
x-on:click.prevent="active = 2">
<i class="fas fa-clipboard-list fa-lg"></i>
<p class="font-semibold text-sm">Booking</p>
</a>
<a href="#" class="flex space-x-2 items-center mr-4 text-gray-400"
x-bind:class="{'text-indigo-600 border-b-4 border-indigo-600': active === 3 }"
x-on:click.prevent="active = 3">
<i class="fas fa-file-medical-alt fa-lg"></i>
<p class="font-semibold text-sm">Report</p>
</a>
</nav>
<!-- End Nav Bar -->
</div>
<div class="col-span-12 sm:col-span-12 md:col-span-6 lg:col-span-6 xxl:col-span-6">
<!-- Start Card List -->
<div class="bg-white p-3 rounded-xl shadow-xl flex items-center justify-between">
<div class="flex space-x-6 items-center">
<div class="relative inline-flex">
<i class="fa-lg fas fa-sort-down w-2 h-2 absolute top-0 right-0 mx-5 my-2 pointer-events-none text-white"></i>
<select class="border-white rounded-xl text-white pl-5 pr-10 bg-pink-600 hover:bg-pink-700 focus:outline-none appearance-none">
<option>All</option>
</select>
</div>
<div class="flex space-x-2 items-center">
<p class="font-semibold">Jonh Cena</p>
<div class="bg-gray-800 rounded-md p-2 flex items-center">
<i class="fab fa-github-alt fa-sm text-white"></i>
</div>
</div>
</div>
<p class="font-semibold text-gray-400">08:02 PM</p>
</div>
<!-- End Card List -->
</div>
<div class="col-span-12 sm:col-span-12 md:col-span-5 lg:col-span-5 xxl:col-span-5">
<!-- Start Card List -->
<div class="bg-white p-3 rounded-xl shadow-xl flex items-center justify-between mt-4">
<div class="flex space-x-6 items-center">
<img src="https://www.nicepng.com/png/detail/395-3955418_paypal-icon-png.png" class="w-auto h-12"/>
<div>
<p class="font-semibold text-base">PayPal</p>
<p class="font-semibold text-xs text-gray-400">Payment Collected</p>
</div>
</div>
<div class="flex space-x-2 items-center">
<div class="bg-yellow-200 rounded-md p-2 flex items-center">
<p class="text-yellow-600 font-semibold text-xs">-C4,678</p>
</div>
</div>
</div>
<!-- End Card List -->
</div>
<div class="col-span-12 sm:col-span-12 md:col-span-7 lg:col-span-7 xxl:col-span-7">
<div class="grid grid-cols-12 gap-4">
<div class="col-span-12 sm:col-span-12 md:col-span-7 lg:col-span-7 xxl:col-span-7">
<!-- Start Card List -->
<div class="relative w-full h-52 bg-cover bg-center group rounded-lg overflow-hidden mt-4 shadow-lg transition duration-300 ease-in-out"
style="background-image: url('https://www.tokkoro.com/picsup/5081898-forest-nature-road.jpg');">
<div class="absolute inset-0 bg-black bg-opacity-50 transition duration-300 ease-in-out"></div>
<div class="relative w-full h-full px-4 sm:px-6 lg:px-4 flex items-center">
<div>
<div class="text-white text-lg flex space-x-2 items-center">
<div class="bg-white rounded-md p-2 flex items-center">
<i class="fas fa-toggle-off fa-sm text-yellow-300"></i>
</div>
<p>Finished Appt</p>
</div>
<h3 class="text-white text-3xl mt-2 font-bold">
120
</h3>
<h3 class="text-white text-lg mt-2 text-yellow-100 ">
4 not confirmed
</h3>
</div>
</div>
</div>
<!-- End Card List -->
</div>
<div class="col-span-12 sm:col-span-12 md:col-span-5 lg:col-span-5 xxl:col-span-5">
<!-- Start Card List -->
<div class="bg-white rounded-xl p-4 shadow-xl mt-4">
<div class="flex flex-col justify-center items-center">
<img src="https://media.karousell.com/media/photos/products/2021/4/16/kajang_3xxk3xxk3xxk22x70_4r3b__1618542693_a779ef2b_progressive.jpg" class="w-full h-40 rounded-lg"/>
</div>
<p class="font-semibold text-lg mt-1 text-left">Traffic Point</p>
<p class="font-semibold text-sm text-gray-400">Kajang,Selangor MY</p>
<div class="flex space-x-2 text-gray-400 items-center mt-2">
<i class="fas fa-map-marker-alt"></i>
<p class="font-semibold text-sm text-gray-400">5km</p>
</div>
</div>
<!-- End Card List -->
</div>
</div>
</div>
</div>
</div>
<div class="col-span-12 sm:col-span-12 md:col-span-12 lg:col-span-4 xxl:col-span-4 px-6 py-6">
<!-- Start profile Card -->
<div class="bg-white rounded-xl p-4 shadow-xl">
<div class="flex flex-col justify-center items-center">
<div class="w-32 h-32 rounded-full bg-gray-300 border-2 border-white mt-2">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQVxhAxJ4D7MOeTTj6kR9PBeZonW5HM7giKjTbEmR-HMBwf3G1VqGnlwpO1kWrdyIZu8_U&usqp=CAU"
class="rounded-full w-auto"
/>
</div>
<p class="font-semibold text-xl mt-1">Safwan</p>
<p class="font-semibold text-base text-gray-400">No Future</p>
<div class="relative p-4 rounded-lg shadow-xl w-full bg-cover bg-center h-32 mt-4"
style="background-image: url('https://images.pexels.com/photos/1072179/pexels-photo-1072179.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500');"
>
<div class="absolute inset-0 bg-gray-800 bg-opacity-50"></div>
<div class="relative w-full h-full px-4 sm:px-6 lg:px-4 flex items-center justify-center">
<div>
<h3 class="text-center text-white text-lg">
Total Income
</h3>
<h3 class="text-center text-white text-3xl mt-2 font-bold">
RM 2000.00
</h3>
</div>
</div>
</div>
</div>
</div>
<!-- End profile Card -->
<!-- Start Card List -->
<div class="bg-white p-3 rounded-xl shadow-xl flex items-center justify-between mt-4">
<div class="flex space-x-6 items-center">
<img src="https://i.pinimg.com/originals/25/0c/a0/250ca0295215879bd0d53e3a58fa1289.png" class="w-auto h-24 rounded-lg"/>
<div>
<p class="font-semibold text-base">Connect Device</p>
<p class="font-semibold text-sm text-gray-400">Autorize device for transfer</p>
</div>
</div>
<div class="flex space-x-2 items-center">
<div class="bg-gray-300 rounded-md p-2 flex items-center">
<i class="fas fa-chevron-right fa-sm text-black"></i>
</div>
</div>
</div>
<!-- End Card List -->
<!-- Start Card List -->
<div class="bg-white rounded-xl p-4 shadow-xl mt-4">
<div class="flex flex-col justify-center items-center">
<img src="https://cdn3d.iconscout.com/3d/premium/thumb/upload-social-media-post-4291893-3569926.png" class="w-auto h-40 rounded-lg"/>
<p class="font-semibold text-xl mt-1">Upload Data</p>
<p class="font-semibold text-sm text-gray-400 text-center">Make your data as zip file <br> and drag here</p>
<button class=" mt-4 bg-indigo-600 hover:bg-indigo-700 shadow-xl text-white font-bold py-2 px-4 rounded">
Upload Now
</button>
</div>
</div>
<!-- End Card List -->
</div>
</div>
</div>
</body>
How to build a Card Dashboard with Tailwind CSS?
Install tailwind css of verion 2.2.4
Use the script
html tag to import the script of Tailwind CSS of the version 2.2.4
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to build a Card Dashboard component
h-full
bg-gradient-to-r
grid
grid-cols-12
gap-0
px-6
py-6
gap-6
bg-white
p-4
flex
mr-4
text-gray-400
text-indigo-600
border-b-4
border-indigo-600
text-sm
p-3
relative
inline-flex
w-2
h-2
absolute
top-0
right-0
mx-5
my-2
text-white
border-white
pl-5
pr-10
bg-pink-600
hover:bg-pink-700
bg-gray-800
p-2
mt-4
w-auto
h-12
text-base
text-xs
bg-yellow-200
text-yellow-600
gap-4
w-full
h-52
bg-cover
bg-center
overflow-hidden
bg-black
bg-opacity-50
px-4
sm:px-6
lg:px-4
text-lg
text-yellow-300
text-3xl
mt-2
text-yellow-100
flex-col
h-40
mt-1
text-left
w-32
h-32
bg-gray-300
border-2
text-xl
text-center
h-24
text-black
bg-indigo-600
hover:bg-indigo-700
py-2
73 steps to build a Card Dashboard component with Tailwind CSS
Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Control the background color of an element to gradient-to-r using the
bg-gradient-to-r
utilities.Use
grid
to create a grid container.Use
grid
to create a grid container.To specify the width between columns, you can use the
gap-0
utilities.Control the horizontal padding of an element to 1.5rem using the
px-6
utilities.Control the vertical padding of an element to 1.5rem using the
py-6
utilities.To specify the width between columns, you can use the
gap-6
utilities.Control the background color of an element to white using the
bg-white
utilities.Control the padding on all sides of an element to 1rem using the
p-4
utilities.Use
flex
to create a block-level flex container.Control the margin on right side of an element to 1rem using the
mr-4
utilities.Control the text color of an element to gray-400 using the
text-gray-400
utilities.Control the text color of an element to indigo-600 using the
text-indigo-600
utilities.Control the border color of an element to b-4 using the
border-b-4
utilities.Control the border color of an element to indigo-600 using the
border-indigo-600
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the padding on all sides of an element to 0.75rem using the
p-3
utilities.Use
relative
to position an element according to the normal flow of the document.Use
inline-flex
to create an inline flex container that flows with text.Use
w-2
to set an element to a fixed width(0.5rem).Use
h-2
to set an element to a fixed height(0.5rem).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.Use the
top-0
utilities to set the top position of a positioned element to 0rem.Use the
right-0
utilities to set the right position of a positioned element to 0rem.Control the horizontal margin of an element to 1.25rem using the
mx-5
utilities.Control the vertical margin of an element to 0.5rem using the
my-2
utilities.Control the text color of an element to white using the
text-white
utilities.Control the border color of an element to white using the
border-white
utilities.Set the left padding of an element to 1.25rem using the
pl-5
utilities classControl the padding on right side of an element to 2.5rem using the
pr-10
utilities.Control the background color of an element to pink-600 using the
bg-pink-600
utilities.Control the background color of an element to pink-700 using the
hover:bg-pink-700
utilities on hover.Control the background color of an element to gray-800 using the
bg-gray-800
utilities.Control the padding on all sides of an element to 0.5rem using the
p-2
utilities.Control the margin on top side of an element to 1rem using the
mt-4
utilities.The
w-auto
utility can be useful if you need to remove an element’s assigned width under a specific condition, like at a particular breakpoint.Use
h-12
to set an element to a fixed height(3rem).Control the text color of an element to base using the
text-base
utilities.Control the text color of an element to xs using the
text-xs
utilities.Control the background color of an element to yellow-200 using the
bg-yellow-200
utilities.Control the text color of an element to yellow-600 using the
text-yellow-600
utilities.To specify the width between columns, you can use the
gap-4
utilities.Use
w-full
to set an element to a 100% based width.Use
h-52
to set an element to a fixed height(13rem).Control the background color of an element to cover using the
bg-cover
utilities.Control the background color of an element to center using the
bg-center
utilities.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Control the background color of an element to black using the
bg-black
utilities.Control the background color of an element to opacity-50 using the
bg-opacity-50
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the horizontal padding of an element to 1.5rem at only small screen sizes using the
sm:px-6
utilities.Control the horizontal padding of an element to 1rem at only large screen sizes using the
lg:px-4
utilities.Control the text color of an element to lg using the
text-lg
utilities.Control the text color of an element to yellow-300 using the
text-yellow-300
utilities.Control the text color of an element to 3xl using the
text-3xl
utilities.Control the margin on top side of an element to 0.5rem using the
mt-2
utilities.Control the text color of an element to yellow-100 using the
text-yellow-100
utilities.Use
flex
to create a block-level flex container.Use
h-40
to set an element to a fixed height(10rem).Control the margin on top side of an element to 0.25rem using the
mt-1
utilities.Control the text color of an element to left using the
text-left
utilities.Use
w-32
to set an element to a fixed width(8rem).Use
h-32
to set an element to a fixed height(8rem).Control the background color of an element to gray-300 using the
bg-gray-300
utilities.Control the border color of an element to 0.5rem using the
border-2
utilities.Control the text color of an element to xl using the
text-xl
utilities.Control the text color of an element to center using the
text-center
utilities.Use
h-24
to set an element to a fixed height(6rem).Control the text color of an element to black using the
text-black
utilities.Control the background color of an element to indigo-600 using the
bg-indigo-600
utilities.Control the background color of an element to indigo-700 using the
hover:bg-indigo-700
utilities on hover.Control the vertical padding of an element to 0.5rem using the
py-2
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a Card Dashboard components, learn and follow along to implement your own components.