Tailwind CSS Gradient Generator

Create stunning gradients with our visual editor.
Choose from 8 directions and 12 trending presets.

Gradient Preview

Gradient Direction

Color Stops

0%
100%

Standard Classes

bg-gradient-to-r from-[#3b82f6] to-[#8b5cf6]

JIT Arbitrary Value

bg-[linear-gradient(to_right,#3b82f6_0%,#8b5cf6_100%)]

Usage Instructions

  • Standard Classes:适用于 2-3 个颜色的简单渐变
  • JIT Arbitrary Value:支持复杂的多颜色和自定义Position
  • Copy后直接粘贴到 className 中使用

流行Gradient preset

How to Use Tailwind CSS Gradients

Tailwind CSS gradients are one of the most powerful features for creating visually stunning interfaces without writing custom CSS. Understanding how to effectively use gradient utilities can transform your designs from basic to extraordinary.

Understanding Gradient Directions

Tailwind provides eight gradient directions using the bg-gradient-to-{direction} pattern. These include cardinal directions (top, right, bottom, left) and diagonal directions (top-right, bottom-right, etc.). Each direction creates a unique visual flow that can guide user attention and create depth in your design.

The most commonly used directions are to-r (left to right) for horizontal layouts and to-b (top to bottom) for vertical sections. Diagonal gradients liketo-br create dynamic, modern aesthetics perfect for hero sections and cards.

Color Stop Utilities

Tailwind uses three utility classes to define gradient color stops: from-{color},via-{color}, and to-{color}. The "from" utility sets the starting color, "via" adds an optional middle color, and "to" defines the ending color.

<!-- Simple two-color gradient -->
<div class="bg-gradient-to-r from-blue-500 to-purple-600">

<!-- Three-color gradient with middle stop -->
<div class="bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500">

<!-- Using arbitrary values for custom colors -->
<div class="bg-gradient-to-r from-[#ff6b6b] to-[#feca57]">

For more complex gradients with multiple color stops or specific positions, you can use Tailwind's JIT (Just-In-Time) mode with arbitrary values. The syntax bg-[linear-gradient(...)] allows you to define CSS linear-gradient values directly in your className. This is perfect for creating sophisticated multi-color gradients that go beyond the standard from-via-to pattern.

When designing with gradients, consider accessibility and readability. Always ensure sufficient contrast between gradient backgrounds and text content. Lighter gradients work well for subtle backgrounds, while vibrant gradients are excellent for call-to-action elements and hero sections. Experiment with different color combinations and directions to find what best suits your brand and design aesthetic.

Quick Reference Guide

Gradient Directions

  • to-t/b/l/r - Cardinal directions
  • to-tr/br/bl/tl - Diagonal directions
  • Choose based on your layout flow

Color Stops

  • from- - Start color
  • via- - Middle color (optional)
  • to- - End color

Usage Examples

bg-gradient-to-r from-blue-500 to-purple-600
bg-gradient-to-br from-pink-500 via-purple-500 to-blue-500

Pro Tips

  • Use diagonal gradients for modern designs
  • Ensure text has proper contrast
  • Test gradients in both light and dark modes