A Tailwind gradient is built from small utility classes. You pick a direction, then add color stops with from-, via- and to-. The result compiles to a normal CSS background-image, so it behaves exactly like a hand-written gradient. The class names changed in Tailwind v4, though, which is why so many copied snippets don’t work as expected.

Tailwind gradient basics
Every Tailwind CSS gradient follows the same pattern. A Tailwind linear gradient needs two parts: a direction utility and at least two color stops.
<!-- Tailwind v4 -->
<div class="bg-linear-to-r from-violet-600 to-rose-400 h-40"></div>
<!-- Tailwind v3 -->
<div class="bg-gradient-to-r from-violet-600 to-rose-400 h-40"></div>
Both lines create a left-to-right fade from violet to rose. The only difference is the direction class. Under the hood, Tailwind turns this into a linear-gradient() on background-image. If you want to understand what the browser does with it, our guide to the CSS linear gradient explains angles, stops and hard edges in plain CSS.
v3 vs v4 class names
| What you want | Tailwind v3 | Tailwind v4 |
|---|---|---|
| Linear, to the right | bg-gradient-to-r | bg-linear-to-r |
| Linear, diagonal | bg-gradient-to-br | bg-linear-to-br |
| Linear, custom angle | bg-[linear-gradient(45deg,...)] | bg-linear-45 |
| Radial | arbitrary value only | bg-radial |
| Conic | arbitrary value only | bg-conic |
| Color stops | from-* via-* to-* | from-* via-* to-* |
Directions use the same shorthand in both versions: t, tr, r, br, b, bl, l and tl.
Color stops: from, via and to
from- sets the start color, to- sets the end color and via- adds a middle color.
<div class="bg-linear-to-r from-cyan-400 via-sky-500 to-indigo-600"></div>
You can move each stop with a percentage:
<div class="bg-linear-to-r from-emerald-400 from-10% via-teal-500 via-40% to-sky-600 to-90%"></div>
Without positions, Tailwind spreads the stops evenly. With them, you control where each color sits, which is useful when a design needs most of the area in one color and a short fade at the edge.
Opacity works with the slash syntax, which is handy for fading into transparency over an image:
<div class="bg-linear-to-t from-black/80 to-transparent"></div>
Tailwind gradient background on a section
A common pattern is a full-width hero section with a Tailwind background gradient behind text. The same bg gradient classes work on buttons, cards and badges.
<section class="bg-linear-to-br from-indigo-700 via-violet-600 to-fuchsia-500 text-white py-24">
<h1 class="text-5xl font-bold">Build faster</h1>
</section>
Check contrast on the lightest part of the gradient, not just the darkest. White text that reads well on indigo can disappear over a pale fuchsia corner.
Tailwind radial gradient
In v4, bg-radial creates a circle-shaped gradient from the center outward.
<div class="bg-radial from-amber-300 to-orange-600 size-64 rounded-full"></div>
To move the center, use an arbitrary position:
<div class="bg-radial-[at_25%_25%] from-white to-sky-500"></div>
In v3 you need an arbitrary value for the whole gradient, for example bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] together with from- and to- classes. For the full set of shapes and sizes, see our CSS radial gradient guide.
Tailwind conic gradient
Conic gradients rotate colors around a point instead of spreading them along a line. Tailwind v4 adds bg-conic with optional angles.
<div class="bg-conic from-rose-500 via-amber-400 to-rose-500 size-48 rounded-full"></div>
<div class="bg-conic-180 from-indigo-600 to-indigo-600 via-sky-300"></div>
Repeating the first color as the last one hides the seam where the gradient meets itself. Our CSS conic gradient article covers pie charts, color wheels and the starting angle.

Tailwind text gradient
A gradient on text uses the same trick as in plain CSS: paint the background, clip it to the text, then make the text transparent.
<h2 class="bg-linear-to-r from-pink-500 to-violet-600 bg-clip-text text-transparent text-4xl font-extrabold">
Gradient headline
</h2>
Keep the element inline-block or give it a width if the gradient looks stretched across empty space. The CSS gradient text guide covers fallbacks and accessibility.
Tailwind border gradient
Tailwind has no built-in gradient border utility. The simplest approach is a wrapper with padding:
<div class="rounded-xl bg-linear-to-r from-cyan-500 to-blue-600 p-[2px]">
<div class="rounded-[10px] bg-white p-6">Card content</div>
</div>
The outer element shows the gradient, and the inner element covers everything except a 2px ring. Match the inner radius to the outer radius minus the border width so the corners stay even.
Smoother color blending in v4
Gradients between distant hues can turn muddy in the middle. Tailwind v4 lets you choose the interpolation color space with a modifier:
<div class="bg-linear-to-r/oklch from-blue-500 to-yellow-400"></div>
Interpolating in OKLCH usually keeps the midpoint bright and saturated. Our article on OKLCH gradients explains why it works better than sRGB for many color pairs.
Hover and dark mode
Every gradient utility works with variants.
<button class="bg-linear-to-r from-sky-500 to-indigo-500 hover:from-sky-400 hover:to-indigo-400 dark:from-sky-700 dark:to-indigo-700 text-white px-6 py-3 rounded-lg">
Get started
</button>
Browsers can’t animate between two gradient images smoothly with a plain transition. If you need a smooth hover effect, fade an overlay’s opacity or animate background-position on a larger gradient instead.
Arbitrary gradients
When the utilities aren’t enough, write the full gradient as an arbitrary value. Spaces become underscores.
<div class="bg-[linear-gradient(135deg,#6d28d9_0%,#db2777_50%,#f59e0b_100%)]"></div>
This is also the easiest way to paste a gradient from a design tool or a Tailwind gradient generator into your markup.
Combining gradients with patterns
Gradients can be layered with other background images, for example a subtle grid or dot texture over a color fade. Our guide to CSS background patterns shows how to build those textures with pure gradients, and you can wrap them in an arbitrary bg-[...] class.
FAQ
Why doesn’t bg-gradient-to-r work in my project?
In Tailwind v4 the class is bg-linear-to-r. If you upgraded from v3, update the class names or check your version.
How do I add three colors to a Tailwind gradient?
Use from-, via- and to- together, for example from-red-500 via-yellow-400 to-green-500.
Can Tailwind make a radial gradient?
Yes. Tailwind v4 has bg-radial. In v3, use an arbitrary value with radial-gradient().
How do I make a transparent gradient in Tailwind?
Use opacity modifiers or transparent, for example from-black/70 to-transparent.