The short version
- In Tailwind CSS v4, linear gradients use bg-linear-to-* for directions and bg-linear-<angle> for angles, replacing the bg-gradient-to-* names from v3.
- Colours are added with from-, via- and to-* utilities, and their positions with percentage utilities such as from-10% and to-90%.
- Tailwind v4 adds bg-radial and bg-conic utilities, with arbitrary values for positions such as bg-radial-[at_25%_25%].
- Tailwind v4 gradients blend in oklab by default, and modifiers such as /oklch, /srgb and /longer change the interpolation.
- Any gradient Tailwind cannot express with utilities can be written as an arbitrary value, such as bg-linear-[25deg,red_5%,yellow_60%].
On this page
A Tailwind gradient is built from two kinds of utility: one that sets the gradient type and direction, such as bg-linear-to-r, and colour stop utilities that fill it, such as from-indigo-500 to-pink-500. In Tailwind CSS v4 the direction utilities were renamed from bg-gradient-to-* to bg-linear-to-*, angles like bg-linear-45 became possible without custom CSS, and radial and conic gradients arrived as first-class utilities.
<div class="h-32 rounded-2xl bg-linear-to-r from-indigo-500 to-pink-500"></div>linear-gradient(to right in oklab, oklch(58.5% 0.233 277.117), oklch(65.6% 0.241 354.308))to right in oklab, with Tailwind's default indigo-500 and pink-500.Everything here follows the official Tailwind background-image documentation. If you want to know what the generated CSS is doing, the CSS linear gradient guide explains the function underneath.
Linear gradients: directions and angles
bg-linear-to-t, -tr, -r, -br, -b, -bl, -l and -tl point the gradient at a side or corner. For any other direction, use an angle: bg-linear-45 or bg-linear-160. Prefix a minus sign for negative angles, as in -bg-linear-45.
| Class | Generated direction | Replaces in v3 |
|---|---|---|
bg-linear-to-r | to right in oklab | bg-gradient-to-r |
bg-linear-to-br | to bottom right in oklab | bg-gradient-to-br |
bg-linear-45 | 45deg in oklab | an arbitrary value |
bg-linear-to-b/srgb | to bottom in srgb | the v3 default blend |
bg-(image:--brand-gradient) | var(--brand-gradient) as the whole image | bg-[image:var(--x)] |
Under the hood, a direction utility sets a variable called --tw-gradient-position and writes background-image: linear-gradient(var(--tw-gradient-stops)), while the colour utilities fill --tw-gradient-stops. The in oklab part is added inside an @supports check, so browsers without interpolation support still get a working sRGB gradient. That split is also why direction and colours can change independently, for example only the end colour on hover or in dark mode with dark:to-violet-900.
Colour stops: from, via and to
from-* sets the start colour, to-* the end colour, and via-* adds one colour in the middle. Every colour in your theme works, including opacity modifiers such as from-indigo-500/60. Add a percentage utility after a colour to move its stop: from-10%, via-30%, to-90%. Arbitrary positions work too, as in from-[21.5%].
<!-- three stops, evenly spaced -->
<div class="bg-linear-to-r from-indigo-500 via-sky-500 to-emerald-500"></div>
<!-- the same stops, pulled towards the edges -->
<div class="bg-linear-to-r from-indigo-500 from-10% via-sky-500 via-30% to-emerald-500 to-90%"></div>Radial and conic gradients in Tailwind v4
bg-radial draws a radial gradient from the centre, and the same colour stop utilities fill it. Move the centre with an arbitrary value, where underscores stand in for spaces: bg-radial-[at_25%_25%]. bg-conic sweeps colours around the centre, and bg-conic-180 rotates the starting angle.
<div class="size-24 rounded-full bg-radial-[at_25%_25%] from-white to-zinc-900 to-75%"></div>
<div class="size-24 rounded-full bg-conic-180 from-indigo-600 via-indigo-50 to-indigo-600"></div>Interpolation modifiers: oklab, oklch and hue direction
Tailwind v4 blends gradients in oklab by default, which already avoids most grey midpoints. Add a modifier after the direction to change it: /srgb matches older designs, /oklch keeps saturation high between distant hues, and /longer, /shorter, /increasing and /decreasing choose the hue direction. The reasoning is in CSS gradient OKLCH interpolation.
from-indigo-500 to-teal-400 with four interpolation settings. The last one takes the long way round the hue circle.Custom gradients and brand colours
For brand colours, add them to your theme and they become available to every colour utility, including from-*, via-* and to-*. For a gradient the utilities cannot express, such as four or more stops or an unusual angle, use an arbitrary value with underscores for spaces, or point a utility at a custom property.
@import "tailwindcss";
@theme {
--color-dusk: oklch(28% 0.09 285);
--color-ember: oklch(70% 0.19 40);
}
:root {
--brand-gradient: linear-gradient(135deg in oklch, var(--color-dusk), var(--color-ember));
}<!-- brand colours through the stop utilities -->
<div class="bg-linear-135 from-dusk to-ember"></div>
<!-- the whole gradient from a custom property -->
<div class="bg-(image:--brand-gradient)"></div>
<!-- a one-off arbitrary gradient -->
<div class="bg-linear-[25deg,red_5%,yellow_60%,lime_90%,teal]"></div>Keeping the brand gradient in one variable means it is written once and used everywhere, which is what makes a gradient recognisable. Gradient branding explains why that consistency matters more than the colours themselves.
Gradient text and hover states in Tailwind
Gradient text uses the same classes plus bg-clip-text and text-transparent. Variants work on stop utilities, so hover:from-pink-500 changes a colour on hover. Gradients themselves do not transition, so for a smooth hover, fade an overlay's opacity or move bg-position instead of swapping stops.
<h1 class="bg-linear-to-r from-violet-600 to-rose-600 bg-clip-text text-5xl font-bold text-transparent">
Launch day
</h1>
<a class="bg-linear-to-r from-violet-600 to-rose-600 bg-size-[200%_100%] bg-left px-5 py-3 text-white transition-[background-position] duration-500 hover:bg-right">
Get started
</a>Avoid
- Copying v3
bg-gradient-to-rinto new v4 projects - Long class lists repeated on every card
/srgbon blends between distant hues- Swapping stops on hover and expecting a smooth fade
Do
- Use
bg-linear-to-*andbg-linear-<angle> - Theme colours or a custom property for brand gradients
- Keep the default oklab, or try
/oklchfor vivid blends - Animate position or an overlay's opacity
More on the text technique, including contrast and fallbacks, is in gradient text in CSS.
Questions people ask
How do I make a gradient in Tailwind CSS?
Combine a direction utility with colour stops, for example bg-linear-to-r from-indigo-500 to-pink-500. Add via-* for a middle colour.
What replaced bg-gradient-to-r in Tailwind v4?
bg-linear-to-r. The v4 names are bg-linear-to-* for directions and bg-linear-<angle> for angles such as bg-linear-45.
Does Tailwind support radial and conic gradients?
Yes, from v4: bg-radial and bg-conic, with arbitrary positions such as bg-radial-[at_25%_25%] and angles such as bg-conic-180.
How do I make gradient text in Tailwind?
Add bg-clip-text and text-transparent to an element with gradient classes, such as bg-linear-to-r from-violet-600 to-rose-600.
Why do my Tailwind v4 gradients look different from v3?
v4 blends in oklab by default and its default palette is defined in oklch. Add /srgb to the direction utility to get the older blend.
Written by Gradiently
The team behind Gradiently, a design tool built around Marks: living gradients that make everything you design look like yours.
See our profile


