CSS gradient text is super cool.
I love the vibe it gives off, and I made this pure CSS gradient text tutorial before.
Hence, in this tutorial you will learn how to create a gradient text in Tailwind CSS 👀.
See the example:
So, let’s get started!
How to create a gradient text color in Tailwind
Let’s get started by creating our headline and add the Tailwind CSS classes we need:
<h1
class="font-extrabold text-transparent text-8xl bg-clip-text bg-gradient-to-r from-purple-400 to-pink-600"
>
Tailwind CSS
</h1>
Those CSS classes will be all we need to create a cool gradient text color.
But first, let’s look at what those Tailwind CSS properties actually do.
These styles below just do the general styling - they are not needed for the liniear gradient effect itself:
text-8xl
: Makes the text font-size 6rem - quite bigfont-extrabold
: Creates a bigger font-weight, so the visual effect pops more
Now, these classes however are the required classes to add the gradient generator to the text:
text-transparent
: This makes the actual text transparent and shows the background (which has the gradient)bg-clip-text
: This makes the gradient background only show on the text outlinebg-gradient-to-{flow}
: This is used to indicate the direction the linear gradient flow: (All directions)from-{color}
: Set the beginning color for the gradient generator - in our case “purple-400”to-{color}
: This sets the gradient end color - in our case “pink-600”
In the CodePen below, you can change the Tailwind CSS classes in the HTML and play around with the styling:
Demo
See the Pen Making gradient text with Tailwind CSS by Chris Bongers (@rebelchris) on CodePen.
Thank you for reading, and let’s connect!
Feel free to subscribe to my email newsletter and connect on Facebook or Twitter