How to use the tailwind gradient generator
- Select the direction for your tailwind gradient using the dropdown menu.
- Choose a From color and a To color from the Tailwind v3 palette.
- Optionally pick a Via color if you need a three-stop gradient.
- Copy the generated
bg-gradient-to-*classes or the equivalent CSS directly into your project.
How Tailwind CSS Gradients Work
Tailwind CSS uses a set of composable utility classes to build linear gradients. Instead of writing a long CSS value, you combine a direction class like bg-gradient-to-r with color stop classes such as from-blue-500 and to-purple-500. Under the hood, Tailwind sets CSS custom properties: --tw-gradient-from, --tw-gradient-via, and --tw-gradient-to. The final background image is assembled automatically.
For example, applying bg-gradient-to-r from-blue-500 to-purple-500 generates this CSS:
background-image: linear-gradient(to right, var(--tw-gradient-stops));
The stops resolve to #3b82f6 transitioning to #a855f7. This tailwind gradient generator computes those hex values for you so you can verify exactly what the browser will render.
Common Direction Classes Reference
Every tailwind css gradient generator needs to map directions correctly. Here is the reference table for all eight linear gradient directions available in Tailwind v3:
| Class | CSS Angle / Keyword | Description |
|---|---|---|
bg-gradient-to-t | to top | Bottom to top |
bg-gradient-to-tr | to top right | Bottom-left to top-right |
bg-gradient-to-r | to right | Left to right |
bg-gradient-to-br | to bottom right | Top-left to bottom-right |
bg-gradient-to-b | to bottom | Top to bottom |
bg-gradient-to-bl | to bottom left | Top-right to bottom-left |
bg-gradient-to-l | to left | Right to left |
bg-gradient-to-tl | to top left | Bottom-right to top-left |
Using the Via Modifier for Three Stops
A standard tailwind gradient uses two stops: a starting color and an ending color. When you need a middle transition point, add the via-{color} class. For instance, from-red-500 via-orange-500 to-yellow-500 creates a sunset effect passing through three distinct hues.
Tailwind handles the math by inserting the via color at the 50% mark of the gradient line. You do not need to specify percentages manually unless you extend the default configuration in tailwind.config.js. If you are working on typography effects rather than backgrounds, check out the text gradient generator instead.
Converting Between Tailwind and Standard CSS
Sometimes you need the raw CSS output rather than utility classes, especially when integrating with frameworks that do not use Tailwind or when debugging rendering issues. This tool provides both formats side by side.
If you already have existing stylesheets and want to migrate them to utility classes, the css to tailwind converter can help automate that process. Conversely, knowing the exact hex codes behind each Tailwind shade ensures your designs remain consistent whether you write bg-blue-500 or background-color: #3b82f6.
Practical Use Cases for Background Gradients
Background gradients appear frequently in modern interfaces. Hero sections often use a subtle bg-gradient-to-b from-slate-900 to-slate-800 to add depth without heavy imagery. Call-to-action buttons might use a vibrant bg-gradient-to-r from-pink-500 to-rose-500 to draw attention.
- Overlays: Place a semi-transparent gradient over images to ensure text readability.
- Loading skeletons: Animate a gradient sweep across placeholder blocks.
- Card backgrounds: Use soft pastel transitions like
from-indigo-50 to-whitefor subtle elevation.
Because these utilities compile down to standard CSS, they perform identically to hand-written gradient rules while keeping your markup clean and maintainable.
Worked examples
| Example | Input | Result |
|---|---|---|
| Blue to Purple right | Direction: r; From Color: blue-500; Via Color (optional): none; To Color: purple-500 | Tailwind Classes: bg-gradient-to-r from-blue-500 to-purple-500; CSS Equivalent: background-image: linear-gradient(to right, #3b82f6, #a855f7);; Direction: to right; From Hex: #3b82f6; To Hex: #a855f7 |
| Sunset bottom-right | Direction: br; From Color: red-500; Via Color (optional): orange-500; To Color: yellow-500 | Tailwind Classes: bg-gradient-to-br from-red-500 via-orange-500 to-yellow-500; CSS Equivalent: background-image: linear-gradient(to bottom right, #ef4444, #f97316, #eab308);; Direction: to bottom right; From Hex: #ef4444; Via Hex: #f97316; To Hex: #eab308 |
| Ocean top | Direction: t; From Color: cyan-500; Via Color (optional): blue-500; To Color: indigo-500 | Tailwind Classes: bg-gradient-to-t from-cyan-500 via-blue-500 to-indigo-500; CSS Equivalent: background-image: linear-gradient(to top, #06b6d4, #3b82f6, #6366f1);; Direction: to top; From Hex: #06b6d4; Via Hex: #3b82f6; To Hex: #6366f1 |
| Fade to transparent | Direction: r; From Color: green-500; Via Color (optional): none; To Color: none | Tailwind Classes: bg-gradient-to-r from-green-500; CSS Equivalent: background-image: linear-gradient(to right, #22c55e, rgb(34 197 94 / 0));; Direction: to right; From Hex: #22c55e; To Hex: transparent |
FAQ
What is a tailwind gradient generator?
It is a tool that helps you select direction and color stop classes from the Tailwind CSS palette and outputs the correct utility class string along with the equivalent raw CSS.
Does Tailwind support radial or conic gradients?
Tailwind v3 only includes linear gradient utilities out of the box. For radial or conic gradients, you would need to write arbitrary values like bg-[radial-gradient(...)] or add custom plugins.
Can I use shades other than 500?
Yes. Tailwind provides shades from 50 to 950 for each color. This tool lists the 500 shade for brevity, but you can substitute any valid shade number in your classes, such as from-blue-200 to-blue-800.
Is the via color required?
No. The via color is optional and only needed for an intermediate color stop. A from color is required: in Tailwind v3 a gradient without a from-* class draws nothing, so this tool asks for one. If you leave out the to color, Tailwind fades the from color (or the via color) out to transparent, and the CSS shown here matches that.
Do these classes work in Tailwind v2?
The bg-gradient-to-* classes with from-, via- and to- exist in Tailwind v2 and v3 with the same names. Tailwind v4 renamed them to bg-linear-to-*, and this tool outputs the v3 names, so switch the prefix if your project is on v4.
How do I make a gradient fade to transparent?
Set the to color to transparent, or leave it out. In Tailwind v3, with no to-* class the end stop is the from color at zero opacity, so the gradient fades out. Pick None for the To color here to see the matching CSS.