Skip to main content

CSS Gradient Generator

A free online tool to visually create CSS linear, radial, and conic gradients and copy the code.

Preview

Gradient Type

Angle

°

Color Stops

%
%

CSS Code

background: linear-gradient(90deg, #3498db 0%, #e74c3c 100%);

Gradient Presets

Key Features

  • 3 Types: Linear, radial, and conic gradients
  • Real-time Preview: See changes instantly
  • Color Stops: Add up to 8 color stops
  • Angle Control: Set angle for linear/conic gradients (0-360°)
  • Position Control: Set each color position from 0-100%
  • Presets: 6 beautiful gradient presets
  • One-Click Copy: Copy CSS code instantly

Gradient Types

1. Linear Gradient

background: linear-gradient(90deg, #3498db 0%, #e74c3c 100%);
  • Colors transition in one direction
  • Direction specified by angle (0° = up, 90° = right, 180° = down, 270° = left)
  • Most commonly used type

Use Cases:

  • Button backgrounds
  • Header backgrounds
  • Card backgrounds

2. Radial Gradient

background: radial-gradient(circle, #3498db 0%, #e74c3c 100%);
  • Colors transition from center outward
  • Creates circular effects
  • Useful for spotlight effects

Use Cases:

  • Background decorations
  • Button hover effects
  • Logo backgrounds

3. Conic Gradient

background: conic-gradient(from 90deg, #3498db 0%, #e74c3c 100%);
  • Colors rotate around the center
  • Perfect for pie charts and color wheels
  • Relatively new feature added in CSS3

Use Cases:

  • Pie charts
  • Progress rings
  • Color wheels

Color Stops

Basic Concept

Color stops define where specific colors start or end in a gradient.

/* 2 colors */
linear-gradient(90deg, #FF0000 0%, #0000FF 100%)

/* 3 colors */
linear-gradient(90deg, #FF0000 0%, #00FF00 50%, #0000FF 100%)

/* 4 colors */
linear-gradient(90deg, #FF0000 0%, #FFFF00 33%, #00FF00 66%, #0000FF 100%)

Position Tips

  • 0%: Starting point
  • 50%: Midpoint
  • 100%: Ending point
  • Overlapping positions create sharp color transitions
  • Even distribution creates smooth transitions

Practical Examples

1. Button Gradient

.button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 12px 24px;
border: none;
border-radius: 8px;
cursor: pointer;
}

.button:hover {
background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

2. Background Overlay

.hero-section {
background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)),
url('background.jpg');
background-size: cover;
}

3. Text Gradient

.gradient-text {
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-size: 48px;
font-weight: bold;
}

4. Progress Bar

.progress-bar {
background: linear-gradient(90deg, #00d2ff 0%, #3a47d5 100%);
height: 8px;
border-radius: 4px;
width: 60%; /* progress state */
}

5. Card Background

.card {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
padding: 30px;
border-radius: 12px;
color: white;
}

Preset Gradients

Sunset

background: linear-gradient(90deg, #FF512F 0%, #F09819 100%);

Warm orange-red combination, vibrant feel

Ocean

background: linear-gradient(135deg, #2E3192 0%, #1BFFFF 100%);

Cool blue-cyan combination, clean and fresh feel

Forest

background: linear-gradient(90deg, #134E5E 0%, #71B280 100%);

Calm teal-green combination, natural feel

Purple Dream

background: linear-gradient(45deg, #C471F5 0%, #FA71CD 100%);

Dreamy purple-pink combination, modern and trendy

Fire

background: radial-gradient(circle, #FDBB2D 0%, #22C1C3 100%);

Radial yellow-cyan combination, dynamic feel

Rainbow

background: linear-gradient(90deg, #FF0000 0%, #FFFF00 33%, #00FF00 66%, #0000FF 100%);

4-color rainbow effect, vibrant and lively

Browser Compatibility

Linear Gradient

  • ✅ Chrome 26+
  • ✅ Firefox 16+
  • ✅ Safari 7+
  • ✅ Edge 12+
  • ✅ All mobile browsers

Radial Gradient

  • ✅ Chrome 26+
  • ✅ Firefox 16+
  • ✅ Safari 7+
  • ✅ Edge 12+
  • ✅ All mobile browsers

Conic Gradient

  • ✅ Chrome 69+
  • ✅ Firefox 83+
  • ✅ Safari 12.1+
  • ✅ Edge 79+
  • ⚠️ Not supported in IE

Performance Optimization

1. Use will-change

.gradient-element {
will-change: background;
}

GPU acceleration for animations

2. Use Images for Complex Gradients

Convert very complex gradients to images for better performance

3. Reusable Classes

.gradient-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

Design Tips

1. Color Selection

  • Similar hues: Smooth transition
  • Complementary colors: Strong contrast
  • 3 or fewer colors: Usually sufficient

2. Angle Selection

  • 90°: Left to right (most common)
  • 180°: Top to bottom
  • 135°: Diagonal (dynamic feel)

3. Use Transparency

background: linear-gradient(90deg,
rgba(52, 152, 219, 0.8) 0%,
rgba(231, 76, 60, 0.8) 100%
);

4. Animations

@keyframes gradient-shift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}

.animated-gradient {
background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
background-size: 200% 200%;
animation: gradient-shift 3s ease infinite;
}

Accessibility Considerations

1. Contrast Ratio

Text on gradients needs sufficient contrast ratio (WCAG standard 4.5:1)

2. Text Readability

/* Improve readability with text shadow */
.text-on-gradient {
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

3. Use Overlays

.gradient-with-overlay::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
}