- Published on
How To Make A Link Underline Animation With Tailwind CSS From Scratch

- What is Tailwind CSS?
- The description of Link Underline Animation ui component
- Why use Tailwind CSS to create a Link Underline Animation ui component?
- The preview of Link Underline Animation ui component
- The source code of Link Underline Animation ui component
- How to create a Link Underline Animation with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to create a Link Underline Animation component
- 13 steps to create a Link Underline Animation 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 Link Underline Animation ui component
Link underline growing animation with tailwindcss
Why use Tailwind CSS to create a Link Underline Animation ui component?
- It can make the building process of Link Underline Animation ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Link Underline Animation component file.
The preview of Link Underline Animation ui component
Free download of the Link Underline Animation's source code
The source code of Link Underline Animation ui component
<div class="min-h-screen bg-gray-100 py-6 flex flex-col justify-center sm:py-12">
<div class="relative py-3 sm:max-w-xl sm:mx-auto">
<a href="#" class="font-display max-w-sm text-2xl font-bold leading-tight">
<span class="link link-underline link-underline-black text-black"> Hover to See the Effect </span>
</a>
<br>
<br>
<a href="#" class="font-display max-w-sm text-2xl font-bold leading-tight">
<span class="link link-underline link-underline-black text-black"> Multi line text will <br>work fine too.</span>
</a>
</div>
</div>
<style>
.link-underline {
border-bottom-width: 0;
background-image: linear-gradient(transparent, transparent), linear-gradient(#fff, #fff);
background-size: 0 3px;
background-position: 0 100%;
background-repeat: no-repeat;
transition: background-size .5s ease-in-out;
}
.link-underline-black {
background-image: linear-gradient(transparent, transparent), linear-gradient(#F2C, #F2C)
}
.link-underline:hover {
background-size: 100% 3px;
background-position: 0 100%
}
</style>
How to create a Link Underline Animation 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 create a Link Underline Animation component
min-h-screen
bg-gray-100
py-6
flex
flex-col
sm:py-12
relative
py-3
sm:max-w-xl
sm:mx-auto
max-w-sm
text-2xl
text-black
13 steps to create a Link Underline Animation component with Tailwind CSS
Set the minimum width/height of an element using the
min-h-screen
utilities.Control the background color of an element to gray-100 using the
bg-gray-100
utilities.Control the vertical padding of an element to 1.5rem using the
py-6
utilities.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Control the vertical padding of an element to 3rem at only small screen sizes using the
sm:py-12
utilities.Use
relative
to position an element according to the normal flow of the document.Control the vertical padding of an element to 0.75rem using the
py-3
utilities.Set the maximum width/height of an element using the
sm:max-w-xl
utilities at only small screen sizes.Control the horizontal margin of an element to auto at only small screen sizes using the
sm:mx-auto
utilities.Set the maximum width/height of an element using the
max-w-sm
utilities.Control the text color of an element to 2xl using the
text-2xl
utilities.Control the text color of an element to black using the
text-black
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to create a Link Underline Animation components, learn and follow along to implement your own components.