- Published on
Most Effective Ways To Create A Fancy Buttons With Tailwind CSS

- What is Tailwind CSS?
- The description of Fancy Buttons ui component
- Why use Tailwind CSS to build a Fancy Buttons ui component?
- The preview of Fancy Buttons ui component
- The source code of Fancy Buttons ui component
- How to build a Fancy Buttons with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to build a Fancy Buttons component
- 20 steps to build a Fancy Buttons 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 Fancy Buttons ui component
Fancy buttons
Why use Tailwind CSS to build a Fancy Buttons ui component?
- It can make the building process of Fancy Buttons ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Fancy Buttons component file.
The preview of Fancy Buttons ui component
Free download of the Fancy Buttons's source code
The source code of Fancy Buttons ui component
<style>
@keyframes hue {
0% {filter:hue-rotate(0deg);}
100% {filter:hue-rotate(80deg);}
}
@keyframes translate {
0% {transform:translate(0,0%);}
100% {transform:translate(0,-75%);}
}
.active img {
animation:hue 1.3s infinite linear alternate;
}
.loading img{
animation:translate 1.3s linear infinite alternate;
opacity:0.8;
filter:contrast(200%);
box-shadow:none !important;
}
.button:hover img{
transform:translate(0px ,-20px);
/* filter:brightness(120%); */
}
.button{
box-shadow:0px 0px 3px 1px gray;
}
.button:active{
transform:scale(0.95);
box-shadow:none !important;
}
.button img{
filter:brightness(110%);
transition:all 0.2s;
}
body{
background:white;
}
</style>
<h1 class="text-xl mx-auto w-max my-5">Fancy Buttons</h1>
<div class="main w-max border flex p-5 mx-auto">
<div class="button mr-2 select-none cursor-pointer w-max relative rounded-sm">
<div class="pic overflow-hidden rounded-sm absolute w-full h-full">
<img class="h-44 w-60" src="https://i.ibb.co/SJxDmYd/image.jpg">
</div>
<div class="text text-gray-600 top-0 font-bold relative p-2 px-4">Cold</div>
</div>
<!-- button end -->
<div class="button loading mr-2 select-none cursor-pointer w-max relative rounded-sm">
<div class="pic overflow-hidden rounded-sm absolute w-full h-full">
<img class="h-44 w-60" src="https://i.ibb.co/LNmvXC8/image-1.jpg">
</div>
<div class="text text-gray-200 top-0 font-bold relative p-2 px-4">Heating...</div>
</div>
<!-- button end -->
<div class="button mr-2 select-none cursor-pointer w-max relative rounded-sm">
<div class="pic overflow-hidden rounded-sm absolute w-full h-full">
<img class="h-44 w-60" src="https://i.ibb.co/mvcDDhM/image-3.jpg">
</div>
<div class="text text-gray-200 top-0 font-bold relative p-2 px-4">Orange</div>
</div>
<!-- button end -->
<div class="button mr-2 select-none cursor-pointer w-max relative rounded-sm">
<div class="pic overflow-hidden rounded-sm absolute w-full h-full">
<img class="h-44 w-60" src="https://i.ibb.co/0Cx0GRg/image-5.jpg">
</div>
<div class="text text-gray-200 top-0 font-bold relative p-2 px-4">Steel</div>
</div>
<!-- button end -->
<div class="button loading mr-2 select-none cursor-pointer w-max relative rounded-sm">
<div class="pic overflow-hidden rounded-sm absolute w-full h-full">
<img class="h-44 w-60" src="https://i.ibb.co/SJxDmYd/image.jpg">
</div>
<div class="text text-gray-700 top-0 font-bold relative p-2 px-4">Applying...</div>
</div>
<!-- button end -->
<!-- use loading and active class in button root -->
</div>
How to build a Fancy Buttons 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 Fancy Buttons component
text-xl
mx-auto
w-max
my-5
flex
p-5
mr-2
relative
overflow-hidden
absolute
w-full
h-full
h-44
w-60
text-gray-600
top-0
p-2
px-4
text-gray-200
text-gray-700
20 steps to build a Fancy Buttons component with Tailwind CSS
Control the text color of an element to xl using the
text-xl
utilities.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Use
w-max
to set an element to a fixed width(max).Control the vertical margin of an element to 1.25rem using the
my-5
utilities.Use
flex
to create a block-level flex container.Control the padding on all sides of an element to 1.25rem using the
p-5
utilities.Control the margin on right side of an element to 0.5rem using the
mr-2
utilities.Use
relative
to position an element according to the normal flow of the document.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.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
w-full
to set an element to a 100% based width.Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Use
h-44
to set an element to a fixed height(11rem).Use
w-60
to set an element to a fixed width(15rem).Control the text color of an element to gray-600 using the
text-gray-600
utilities.Use the
top-0
utilities to set the top position of a positioned element to 0rem.Control the padding on all sides of an element to 0.5rem using the
p-2
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the text color of an element to gray-200 using the
text-gray-200
utilities.Control the text color of an element to gray-700 using the
text-gray-700
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a Fancy Buttons components, learn and follow along to implement your own components.