Skip to content

How to style SVG tags linearGradient the Tailwind way when using fill="url(#a)"? #3745

Discussion options

You must be logged in to vote

Ha someone answered on StackOverflow :)

To style the linearGradient colors I had to use the stopColor attribute on the <stop> elements.

<svg
	className="w-32 h-32 text-blue-500"
	viewBox="0 0 17 17"
	xmlns="http://www.w3.org/2000/svg"
>
	<defs>
		<linearGradient x1="50%" y1="92.034%" x2="50%" y2="7.2%" id="a">
			<stop offset="0%" stopColor="currentColor" />
			<stop stopOpacity={0} offset="100%" stopColor="#fff" />
		</linearGradient>
	</defs>
	<circle
		stroke="currentColor"
		fill="url(#a)"
		cx={8.5}
		cy={8.5}
		r={6}
		fillRule="evenodd"
		fillOpacity={0.8}
	/>
</svg>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by deadcoder0904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant