Gradients & Backgrounds
Twigwind provides powerful utilities for creating linear gradients and managing background properties.
💡 Tip: Gradients and background utilities work seamlessly with hover states and responsive prefixes.
Linear Gradients
Create beautiful linear gradients using the gradient- utility with direction and color combinations.
Basic Syntax
gradient-{direction}-{color1}-{color2}-{color3}...
Directional Gradients
gradient-to-r-red-blue
gradient-to-l-green-yellow
gradient-to-t-purple-pink
gradient-to-b-blue-cyan
<div class="gradient-to-r-red-blue">Left to right</div>
<div class="gradient-to-l-green-yellow">Right to left</div>
<div class="gradient-to-t-purple-pink">Bottom to top</div>
<div class="gradient-to-b-blue-cyan">Top to bottom</div>
Diagonal Gradients
gradient-to-tr-red-blue
gradient-to-tl-green-yellow
gradient-to-br-purple-pink
gradient-to-bl-blue-cyan
<div class="gradient-to-tr-red-blue">Top-left to bottom-right</div>
<div class="gradient-to-tl-green-yellow">Top-right to bottom-left</div>
<div class="gradient-to-br-purple-pink">Top-left to bottom-right</div>
<div class="gradient-to-bl-blue-cyan">Top-right to bottom-left</div>
Angle Gradients
gradient-45deg-red-blue
gradient-90deg-green-yellow
gradient-135deg-purple-pink
gradient-180deg-blue-cyan
<div class="gradient-45deg-red-blue">45 degree angle</div>
<div class="gradient-90deg-green-yellow">90 degree angle</div>
<div class="gradient-135deg-purple-pink">135 degree angle</div>
<div class="gradient-180deg-blue-cyan">180 degree angle</div>
Multi-Color Gradients
gradient-to-r-red-yellow-green
gradient-to-b-blue-purple-pink
gradient-45deg-red-orange-yellow-green
<div class="gradient-to-r-red-yellow-green">Three colors</div>
<div class="gradient-to-b-blue-purple-pink">Three colors vertical</div>
<div class="gradient-45deg-red-orange-yellow-green">Four colors at angle</div>
Background Utilities
Control background behavior with clip utilities and dynamic image backgrounds.
Background Clip
Control how background extends within an element's box model.
clip-border
clip-padding
clip-content
<div class="gradient-to-r-red-blue clip-border">Border box</div>
<div class="gradient-to-r-green-yellow clip-padding">Padding box</div>
<div class="gradient-to-r-purple-pink clip-content">Content box</div>
Background Images
Set background images dynamically using the image-url- utility.
Background Image
<div class="image-url-https://images.unsplash.com/photo-1506905925346-21bda4d32df4">
Content with background image
</div>
⚠️ Note: Use underscores (_) in place of spaces in URLs when using the image-url- utility.
Interactive States
Combine gradients with hover states for dynamic effects.
Hover for gradient
Hover to reverse
<div class="bg-blue hover:gradient-to-r-purple-pink">
Hover for gradient
</div>
<div class="gradient-to-r-red-blue hover:gradient-to-l-blue-red">
Hover to reverse gradient
</div>
Responsive Gradients
Use responsive prefixes to create different gradients at different screen sizes.
<div class="gradient-to-r-red-blue md:gradient-to-b-green-yellow lg:gradient-45deg-purple-pink">
Responsive gradient
</div>
Available Directions
| Direction | CSS Equivalent | Description |
|---|---|---|
to-r | to right | Left to right |
to-l | to left | Right to left |
to-t | to top | Bottom to top |
to-b | to bottom | Top to bottom |
to-tr | to top right | Bottom-left to top-right |
to-tl | to top left | Bottom-right to top-left |
to-br | to bottom right | Top-left to bottom-right |
to-bl | to bottom left | Top-right to bottom-left |
{angle}deg | {angle}deg | Custom angle (0-360) |
✅ All Twigwind colors work with gradients, including custom hex values and RGB colors.