I am trying Nextjs and tailwind css i created a simple page with that but now i am facing a problem that i want to make the button a linear gradient color border in tailwind css how can i do that with my code?
<Link href={'/about'}>
<button className="bg-black-500 hover:bg-blue-700 mt-5 text-white font-bold py-2 px-4 rounded-full border border-blue-500 shadow-md transition duration-300 ease-in-out transform hover:scale-105">
Learn More
</button>
</Link>
2
Answers
This can be easily done by using
bg-gradient-to
class withfrom
andto
colors.For example :
Here is the code to make your button’s background into a linear gradient:
You can find the detailed explanation about the tailwind CSS linear gradient classes here https://tailwindcss.com/docs/background-image#linear-gradients
If you want to make it look like it has its border as the linear gradient color then you can try something like this:
It needs you to create another element inside it which will take the background color of the parent container where it resides and our main button will have a full bg gradient. That will create an illusion of having a border gradient. I am sure there might be other ways, including using pseudo-elements to create this effect.