CSS Gradient Generator
Build CSS gradients with draggable stops, live geometry, modern color-space options, syntax checks, and copy-ready CSS output.{{ cssCode }}
| Stop | Color | Position | Alpha | CSS stop | Copy |
|---|---|---|---|---|---|
| {{ row.stop }} | {{ row.color }} | {{ row.position }} | {{ row.alpha }} | {{ row.cssStop }} |
| Check | Status | Detail | Copy |
|---|---|---|---|
| {{ row.check }} | {{ row.status }} | {{ row.detail }} |
CSS gradients turn a color transition into an image value that the browser paints from instructions in the stylesheet. They are common in hero backgrounds, call-to-action buttons, product cards, overlays, badges, and decorative accents because the same value can scale with the element instead of relying on a fixed bitmap.
A useful gradient is more than a list of colors. The geometry defines where the transition travels, color stops define where each color becomes exact, and the interpolation space defines the mathematical route between neighboring stops. Reusing the same blue, violet, and teal anchors can produce directional light, a centered glow, or a circular accent depending on those choices.
- Linear
- A transition along a gradient line. Angles are useful for directional backgrounds, button sheen, and panel depth.
- Radial
- A transition from a center point outward through a circle or ellipse. It fits highlights, glows, and vignette-style backgrounds.
- Conic
- A transition around a center point. It fits rings, wheels, segmented accents, and sweep effects.
Color stops are the anchors a designer can audit. Their order and percentages decide how much room each fade, band, or highlight receives. Two stops make a simple transition; three or more stops can create glass overlays, hard stripes, soft focus points, and brand blends. Transparency belongs to the stop itself, so the same value can look very different over a photograph, a dark panel, or a neutral page background.
CSS has color-stop fixup rules for omitted or backward positions. Those rules keep many gradients paintable, but they can also hide a mistake in a handoff file. When an exact visual needs to survive code review, sorting stops and checking percentages is safer than trusting automatic repair.
Modern color syntax adds another variable. Interpolation can be requested in spaces such as sRGB, Display P3, Rec. 2020, Lab, LCH, OKLab, OKLCH, HSL, HWB, or XYZ, and polar spaces can specify a hue route. A muddy midpoint in one color space may become cleaner in another, but browser support, contrast, and the real component background still decide whether the gradient is ready to ship.
How to Use This Tool:
Start with the closest visual recipe, then check the function, stop list, and output shape before pasting the CSS into a project.
- Pick
Gradient preset. Use a preset as a starting point, or chooseCustom gradientwhen the stop stack should be built from scratch. - Set
Gradient type.Linearuses an angle,Radialuses shape, size, and center percentages, andConicuses a start angle around the center point. - Choose
Code formatandColor interpolation. KeepBrowser defaultfor familiar syntax, or choose a named color space when the final browser set supports modern interpolation. - Edit
Color stops. Drag or click the stop rail for rough placement, then use each row for exact HEX color, percentage position, and alpha. - Open
Advancedfor repeating functions, selector rules, custom properties, fallback color, preview surface, or preview dimensions. - Review
Gradient Preview,Stop Ledger, andSyntax Audit. Copy fromGradient CSSonly after any warnings are intentional.
If Color syntax reports Sanitized, replace the affected color with a valid HEX value and recheck the preview before using the CSS.
Interpreting Results:
Use Gradient CSS as the copy source. The preview is a visual check, while the generated declaration, selector rule, custom property, SCSS variable, @layer block, or Tailwind arbitrary utility is the text the target project will parse.
| Result cue | Meaning | Verification step |
|---|---|---|
Color stops: Ready |
The exported stop count is usable, and positions are in ascending order. | Compare Stop Ledger with the intended color order before copying. |
Color syntax: Sanitized |
At least one typed color was not accepted as HEX and was replaced with a safe value for output. | Correct the color field and confirm the affected CSS stop fragment. |
Interpolation: Modern |
The output asks for an explicit color interpolation mode. | Test in the browsers that will render the final component. |
| Repeating range warning | The first and final stop positions are equal, so the repeat interval has no useful span. | Move the final stop farther from the first stop or turn repeating off. |
Ready means the generated value is structurally usable. Text contrast, brand fit, responsive cropping, and support for modern interpolation still need review in the real component.
Technical Details:
CSS gradient syntax is built from the function name, optional geometry, optional color interpolation, and a color-stop list. The value is an image, so background-image is the narrow property for component backgrounds. The broader background shorthand can be valid, but it may also reset position, repeat, size, attachment, and other background subproperties in the same rule.
Geometry controls how stop positions are interpreted. Linear gradients place stops along a gradient line. Radial gradients measure outward from a center through a circle or ellipse. Conic gradients place stops around a full turn, with the start angle defining where the sweep begins. Repeating functions keep the selected geometry and repeat the interval from the first stop to the final stop.
Gradient Syntax Core:
| Gradient kind | Geometry part | Stop-position meaning | Common use |
|---|---|---|---|
linear-gradient() |
Angle in degrees, or a directional keyword in hand-written CSS. | Percentage along the gradient line. | Banners, buttons, panels, and directional lighting. |
radial-gradient() |
Circle or ellipse, size keyword, and center point. | Percentage moving outward from the center. | Highlights, glows, vignettes, and focal backgrounds. |
conic-gradient() |
Start angle and center point. | Percentage or angle around a complete turn. | Rings, wheels, accent dials, and segmented sweeps. |
repeating-* |
Same geometry as the selected base function. | First-to-final stop range becomes the repeat interval. | Stripes, bands, radial ripples, and repeated conic accents. |
Color interpolation happens between adjacent stops. Default syntax leaves the color route to the browser's supported default. An explicit clause such as in oklab, in display-p3, or in hsl longer hue asks for a specific color space or hue route. That changes the calculated midpoints, but unsupported syntax still needs browser testing.
Predictable handoff depends on bounded stop data. Stop colors are normalized to three- or six-digit HEX values, positions are clamped from 0% to 100%, and alpha values are clamped from 0% to 100%. Fully opaque stops export as HEX. Translucent stops export as rgba() so opacity remains attached to the stop.
Validation Rules:
| Rule | Applied behavior | Result cue |
|---|---|---|
| Stop count | At least 2 stops are needed; only the first 10 stops are exported. |
Check gradient inputs appears when the count needs review. |
| Stop color | HEX input is normalized; invalid color text is replaced with a safe HEX value. | Color syntax reports Ready or Sanitized. |
| Stop position | Positions are clamped from 0% to 100%. |
Color stops reports whether positions are ascending. |
| Alpha | 100% keeps HEX output; lower values export rgba(). |
Stop Ledger shows the exact CSS stop fragment. |
| Interpolation | Browser default omits the clause; other choices emit syntax such as in lab, in display-p3, in oklab, or in hsl longer hue. |
Interpolation reports Compatible or Modern. |
| Repeating range | The first and final stop positions need a positive range for useful repetition. | A warning appears when repeating stops begin and end at the same position. |
A fallback background color remains separate from the gradient image. When included, it gives failed or older rendering paths a solid color before the gradient declaration. Tailwind output emits an arbitrary background utility from the same gradient value; test it in the project build because extraction and safelisting rules vary by setup.
Worked Examples:
A product hero background can start from Product hero, Linear, 135deg, and Browser default. The summary should show linear 135deg with 3 stops, and Gradient CSS should include linear-gradient(135deg, #2563eb 0%, #7c3aed 46%, #14b8a6 100%) in the selected output shape.
A glass overlay needs an opacity check before approval. Choose Glass overlay, open Stop Ledger, and confirm that stops below 100% alpha appear as rgba() fragments while fully opaque stops stay as HEX. Use the Transparent grid preview surface when the gradient will sit over an image or variable background.
A repeating stripe needs a positive repeat interval. If the first and final stops both sit at 0%, Syntax Audit warns that the range is not useful. Move the final stop to 12% for tight stripes or 100% for a full-span repeat, then confirm the warning clears.
For a utility-first handoff, choose Tailwind arbitrary utility as the code format. Gradient CSS becomes a single arbitrary background utility, while Stop Ledger and Syntax Audit still show the stop fragments and warning state behind it.
Out-of-order custom stops are a common troubleshooting case. Put one stop at 80% and the next at 40%; the preview may still paint, but Color stops reports that positions need sorting. Click Sort and confirm the corrected order before copying.
FAQ:
Why did one stop become rgba()?
A stop with alpha below 100% exports as rgba() so the transparency stays attached to that stop. Fully opaque stops remain HEX in Stop Ledger and Gradient CSS.
Why does Syntax Audit warn about stop order?
At least one stop position is lower than a previous stop. CSS can repair that during stop fixup, but the painted result can surprise you. Use Sort, then confirm the order in Stop Ledger.
When should I choose OKLab or OKLCH?
Use OKLab or OKLCH when you want to test a perceptual color path rather than default interpolation. Because those modes emit modern syntax, check target browser support before relying on the final appearance.
Why does the preview look different in my page?
The preview size and surface are controlled checks. The target component may have different dimensions, text, images, stacking, or background settings, so test the final CSS in the real layout before approval.
Do gradient settings have to be sent to a server?
The gradient value, preview, stop ledger, syntax audit, and JSON output are created in the browser page. Current settings can appear in the page URL, so treat shared links as visible configuration.
Glossary:
- Color stop
- A color anchor in the gradient, usually paired with a percentage position.
- Stop rail
- The interactive strip for selecting, dragging, clicking, or nudging a color stop position.
- Interpolation
- The color path between two adjacent stops.
- Stop fixup
- The CSS rule process that resolves missing or backward stop positions before painting.
- Repeating gradient
- A gradient function that repeats the first-to-final stop interval.
- CSS custom property
- A reusable variable name that can hold the generated gradient value.
- Syntax Audit
- The result table that summarizes function, stop, color, interpolation, and output-shape checks.
- Tailwind arbitrary utility
- A utility-class form that places the generated gradient value inside a Tailwind arbitrary background class.
References:
- CSS Images Module Level 4, W3C.
- CSS Color Module Level 4, W3C.
- Using CSS gradients, MDN Web Docs.
- color-interpolation-method CSS type, MDN Web Docs.
- conic-gradient() CSS function, MDN Web Docs.