Last updated: 15 January 2026

Tailwind CSS Gradient

Create beautiful CSS gradients in Tailwind with bg-gradient-to-r, from-*, via-*, and to-* utilities. Covers linear gradients, directions, color stops, and text gradients.


Interactive Gradient Color Stops Playground

Try each class live and inspect the CSS output.

Utility class
from-emerald-400 to-blue-500
CSS output
background-image: linear-gradient(to right, rgb(52 211 153), rgb(59 130 246));

Gradients add visual depth and polish to your designs without needing images. Tailwind CSS provides a complete set of gradient utilities that let you create linear gradients with multiple color stops — all from your HTML classes.

How to Create Tailwind Gradients

A Tailwind gradient requires three parts:

  1. Directionbg-gradient-to-{direction} sets the gradient direction.
  2. Starting colorfrom-{color} sets where the gradient begins.
  3. Ending colorto-{color} sets where the gradient ends.
HTML
1<div class="bg-gradient-to-r from-blue-500 to-purple-600 text-white p-6 rounded-lg">
2 Left to right gradient
3</div>

Left to right gradient

Top to bottom gradient

Top-left to bottom-right

Gradient Directions

Tailwind supports 8 gradient directions:

| Class | Direction | |-------|-----------| | bg-gradient-to-t | Bottom to top | | bg-gradient-to-tr | Bottom-left to top-right | | bg-gradient-to-r | Left to right | | bg-gradient-to-br | Top-left to bottom-right | | bg-gradient-to-b | Top to bottom | | bg-gradient-to-bl | Top-right to bottom-left | | bg-gradient-to-l | Right to left | | bg-gradient-to-tl | Bottom-right to top-left |

HTML
1<div class="bg-gradient-to-tr from-cyan-500 to-blue-500 p-4 rounded">
2 Diagonal gradient
3</div>
to-t
to-tr
to-r
to-br
to-b
to-bl
to-l
to-tl

Three-Color Gradients with Via

Add a middle color stop with via-{color} for richer gradients:

HTML
1<div class="bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-white p-6 rounded-lg">
2 Three-color gradient
3</div>

Indigo → Purple → Pink

Green → Blue → Purple

Yellow → Red → Pink

Gradient Color Stops with Opacity

You can use colors with opacity modifiers for softer gradients:

HTML
1<div class="bg-gradient-to-r from-blue-500/80 to-transparent p-6 rounded-lg">
2 Gradient fading to transparent
3</div>

Here are some commonly used gradient color pairs:

HTML
1<!-- Sunset -->
2<div class="bg-gradient-to-r from-orange-500 to-pink-500"></div>
3
4<!-- Ocean -->
5<div class="bg-gradient-to-r from-cyan-500 to-blue-600"></div>
6
7<!-- Forest -->
8<div class="bg-gradient-to-r from-green-400 to-emerald-600"></div>
9
10<!-- Berry -->
11<div class="bg-gradient-to-r from-purple-600 to-pink-500"></div>
12
13<!-- Metal -->
14<div class="bg-gradient-to-b from-gray-200 to-gray-500"></div>
Sunset
Ocean
Forest
Berry
Metal

Gradient Buttons

Gradients work great on interactive elements:

HTML
1<button class="bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-bold py-3 px-6 rounded-lg transition-all duration-200">
2 Gradient Button
3</button>

Responsive Gradients

Change gradient direction or colors at different breakpoints:

HTML
1<div class="bg-gradient-to-b md:bg-gradient-to-r from-blue-500 to-purple-600 p-6 rounded-lg">
2 Vertical on mobile, horizontal on desktop
3</div>

✏️ Arbitrary Value Usage

For custom gradient angles or color stops, use arbitrary values:

HTML
1<div class="bg-[linear-gradient(135deg,#667eea_0%,#764ba2_100%)]">
2 Custom angle gradient
3</div>

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates