Gradient
Background gradient utilities generated for every combination of two or three $theme-colors tokens - .gradient-{from}-{to} and .gradient-{from}-{via}-{to} - plus directional (.gradient-to-{side}-{from}-{to}) and radial (.gradient-radial-{from}-{to}) variants.
Two-color gradients
Combine any two theme color keys to produce a linear gradient background.
Preview
primary -> success
danger -> warning
indigo -> pink
<div class="gradient-primary-success text-white p-4">
primary to success
</div>
<div class="gradient-indigo-pink text-white p-4">
indigo to pink
</div>
Three-color gradients
Chain a third color for a smoother multi-stop transition: .gradient-{from}-{via}-{to}.
primary -> purple -> danger
teal -> cyan -> blue
<div class="gradient-primary-purple-danger text-white p-4">
Three-stop gradient
</div>
Every distinct pairing is generated. Since gradients loop over the full$theme-colorsmap against itself (and again for the three-stop variant), every unique combination produces a class. Pairs that repeat the same color - such as.gradient-primary-primary- are skipped, and extending$theme-colorsautomatically extends the gradient set.
Direction
Point the gradient toward any side or corner with .gradient-to-{side}-{from}-{to}. Available sides: top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.
to right: primary -> success
to top right: indigo -> pink
to left: danger -> warning
<div class="gradient-to-right-primary-success text-white p-4">
Horizontal gradient
</div>
<div class="gradient-to-top-right-indigo-pink text-white p-4">
Diagonal gradient
</div>
Radial
Create a circular gradient radiating from the center with .gradient-radial-{from}-{to}.
radial: primary -> success
radial: indigo -> pink
<div class="gradient-radial-primary-success text-white p-4">
Circular gradient
</div>
Reference
| Pattern | Example | CSS produced |
|---|---|---|
.gradient-{a}-{b} | .gradient-primary-danger | linear-gradient(to bottom, primary, danger) |
.gradient-{a}-{b}-{c} | .gradient-primary-purple-danger | linear-gradient(to bottom, primary, purple, danger) |
.gradient-to-{side}-{a}-{b} | .gradient-to-right-primary-danger | linear-gradient(to right, primary, danger) |
.gradient-radial-{a}-{b} | .gradient-radial-primary-danger | radial-gradient(circle, primary, danger) |