Creating Beautiful Gradient Backgrounds in Tailwind CSS
Master gradient backgrounds from simple two-color fades to complex multi-stop gradients.
gradientsbackgroundsdesignvisual
beginner8 min readtutorial
Basic Gradients
Tailwind provides gradient utilities for common directions and color stops. The basic pattern is: bg-gradient-to-{direction} + from-{color} + to-{color}.
<!-- Simple two-color gradients -->
<div class="bg-gradient-to-r from-blue-500 to-purple-500">Left to right</div>
<div class="bg-gradient-to-b from-sky-400 to-blue-600">Top to bottom</div>
<div class="bg-gradient-to-br from-pink-500 to-orange-400">Diagonal</div>Three-Color Gradients
Use the via-{color} utility to add a middle color stop:
<div class="bg-gradient-to-r from-green-400 via-blue-500 to-purple-600">
Three color gradient
</div>
<div class="bg-gradient-to-r from-amber-200 via-rose-400 to-violet-500">
Sunset gradient
</div>Gradient Directions
- to-t: to top
- to-tr: to top right
- to-r: to right
- to-br: to bottom right
- to-b: to bottom
- to-bl: to bottom left
- to-l: to left
- to-tl: to top left
Transparent Gradients
<!-- Fade to transparent -->
<div class="bg-gradient-to-t from-black/80 to-transparent">
Image overlay that fades up
</div>
<!-- Vignette effect -->
<div class="bg-[radial-gradient(ellipse_at_center,transparent_0%,black_100%)]">
Radial vignette
</div>Custom Stop Positions
<!-- Custom positions using arbitrary values -->
<div class="bg-gradient-to-r from-blue-500 from-10% via-purple-500 via-50% to-pink-500 to-90%">
Custom stop positions
</div>Frequently Asked Questions
Can I create radial gradients?
Tailwind's built-in utilities are for linear gradients. For radial gradients, use arbitrary values: bg-[radial-gradient(circle,_#3b82f6,_#8b5cf6)]
How do I animate a gradient?
Use CSS animations with background-position and background-size. Set a larger background size (like 200%) and animate the position.
Try Our Color Tools
50+ free tools for Tailwind CSS developers. No signup required.
Explore Tools