TToolbox
▧

Gradient Generator

Build CSS gradients visually

About this tool

CSS Gradients (W3C CSS Images Module Level 3) define the modern visual aesthetic of web UI design—powering hero backgrounds, vibrant CTA buttons, and glowing borders. Compared to raster images, CSS gradients load instantaneously with zero network overhead, scale infinitely without pixelation, and render with full GPU acceleration. However, manually calculating stop positions, angles, and color space interpolations often yields muddy transitions. This tool provides visual manipulation of Linear, Radial, and Conic gradients with one-click cross-browser CSS code export.

How to Use This Tool (Step-by-Step)

1

Select Gradient Type & Angle

Select your gradient mode (Linear, Radial, Conic) and drag the directional dial or type degrees (e.g., `135deg`) to adjust light angles.

2

Add Color Stops & Opacity

Click along the color track to insert multiple color stops. Adjust color values, alpha transparency, and percentage positions (0%–100%).

3

Copy Production CSS Rule

Inspect full-canvas rendering in real time. Copy standard, vendor-prefix safe `background` CSS rules directly into your stylesheet.

Linear, Radial & Conic Modes

Complete support across all three CSS specs: directional Linear gradients, focal Radial glows, and 360° Conic color wheels.

Muddy Transition Suppression

Prevents muddy grey desaturation dead zones common in standard sRGB interpolation, preserving vibrant gradient luminosity.

100% Client-Side Air-Gapped

Gradient computations execute strictly inside local browser memory. Unreleased brand identity palettes remain 100% confidential.

Gradient Design Principles & UI Tips

  • •Use analogous colors (30°–60° apart): Blue-to-purple transitions look luscious. Complementary transitions (red-to-green) produce muddy desaturated brown bands.
  • •Insert a middle stop to kill dead zones: For wide hue spans, place a bright intermediate color stop at 50% to bridge luminance smoothly.
  • •Creating gradient text: Apply `background-clip: text` paired with `-webkit-text-fill-color: transparent` over any gradient background rule.

Code & Transformation Examples

CSS Gradient Syntax Reference Benchmark

CSS Code Syntax
/* 1. 经典线性渐变 (45度倾斜) */
background: linear-gradient(45deg, #4f46e5 0%, #06b6d4 100%);

/* 2. 径向圆形光晕渐变 */
background: radial-gradient(circle at center, #ec4899 0%, #3b82f6 100%);

/* 3. 圆锥旋转渐变 (色轮) */
background: conic-gradient(from 0deg, red, yellow, green, blue, red);
GPU Acceleration
相比一张 500KB 的大尺寸背景图片,CSS 渐变代码仅仅占用不到 100 字节,首屏 FCP 加载提速 90% 以上,且在 4K/8K 视网膜屏幕上绝无任何马赛克!

* All modern browsers support unprefixed gradient properties natively with high-performance GPU backing.

Tailwind CSS & Dynamic Variables Snippet

Tailwind CSS Classes
<button class="bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 text-white font-bold py-2 px-4 rounded-xl shadow-lg hover:opacity-90 transition">
  高亮 CTA 按钮
</button>
Dynamic Theme Control
:root {
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}
.card { background: var(--primary-gradient); }

* Wrapping gradients in CSS variables allows seamless one-line theme overrides between light and dark modes.

Frequently Asked Questions

Q: Why do gradients use `background` instead of `background-color`?

A: Gradients are classified as generated `<image>` types under CSS specifications. They belong in `background` or `background-image`, not `background-color`.

Q: How do I create repeating striped pattern backgrounds?

A: Use `repeating-linear-gradient()` with adjacent hard color stops (`#000 0 10px, #fff 10px 20px`) to render seamless vector stripe patterns.

Q: What are the advantages of modern OKLCH color space gradients?

A: OKLCH gradients (`in oklch`) interpolate within a perceptually uniform color space, completely eliminating the luminance dips of legacy sRGB.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/