TapCub is live — analytics, insights and live chat, free on one platform

Free tool CSS gradient generator with draggable color stops

Pick colors, drag the stops and watch the preview change. The preview is painted by exactly the CSS you copy, so what you see is what your page will render. Linear, radial and conic gradients, repeating patterns, opacity and a Tailwind class are all here.

  • Linear, radial and conic
  • Works with a finger or a mouse
  • Runs locally

Design the gradient, copy the CSS

Start from the sample or a preset. Tap the bar to add a color stop, drag a handle to move it.

Generator

Color stops

Tap an empty spot on the bar to add a stop. Drag a handle to move it; arrow keys nudge it and Delete removes it.

Editing stop 1

Gradient type

Quick directions

Presets

CSS
.gradient {
  background-color: #4f46e5;
  background-image: linear-gradient(135deg, #4f46e5 0%, #a855f7 50%, #ec4899 100%);
}
Tailwind class
bg-[linear-gradient(135deg,#4f46e5_0%,#a855f7_50%,#ec4899_100%)]
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

Use this tool often? Save it to My tools.Saved to My tools. Find it any time at the top of the free tools page. You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.

Problem or suggestion?Send feedbackChat with support

Version v1.0Updated Update history

Read the output

What each line of the CSS does

The code block is short on purpose. Here is what you are pasting.

  • Linear, radial, conic and repeating
  • Drag stops on touch or mouse
  • CSS and Tailwind output
CSS gradient generator illustration: Build linear, radial and conic gradients with draggable color stops, then copy the CSS or a Tailwind class
CSS gradient generator, illustrated

background-color

A solid fallback in the first stop’s color. It is only written when every stop is fully opaque; with transparency it would show through and change the look.

background-image

The gradient itself. A gradient is an image, so it layers with other backgrounds: separate several with commas and the first one is drawn on top.

Two background-image lines

When you choose OKLab or OKLCH, the first line is the sRGB version and the second adds in oklab. A browser that cannot parse the second line keeps the first.

Tailwind class

An arbitrary value such as bg-[linear-gradient(135deg,#4f46e5_0%,#ec4899_100%)]. Underscores stand for spaces, so it can sit directly in a class attribute.

A gradient has no size of its own: it fills the element’s box. The same CSS on a wide banner and a square card gives different slopes for corner-to-corner effects, so check it at the real size.

How to use it

From two colors to production CSS

Most gradients take under a minute.

  1. 1

    Choose a type

    Linear for backgrounds and buttons, radial for glows and spotlights, conic for color wheels, pie slices and angular sheens. Or start from a preset.

  2. 2

    Set the stops

    Tap the bar to add colors and drag them into place. Select a stop to type an exact color, position or opacity. Two stops at the same position make a hard edge.

  3. 3

    Aim it

    For linear, set the angle with the slider or the arrow buttons. For radial and conic, drag the center handle on the preview or tap where the middle should be.

  4. 4

    Copy

    Copy the CSS rule into your stylesheet, or the class into your Tailwind markup. The share link restores the whole design later.

How CSS reads it

Angles, lengths and stops

These rules come from the CSS Images specification and explain most surprises.

  • 0deg points up and angles grow clockwise: 90deg runs left to right, 180deg (the default) top to bottom
  • The gradient line is long enough that the corners get the pure end colors: |W × sin A| + |H × cos A|
  • A stop placed before an earlier one is moved up to it, which creates a hard edge
  • Colors blend in premultiplied RGBA, so fading to transparent does not turn grey
The three gradient functions
FunctionColors change alongTypical use
linear-gradient()a straight line at an anglepage and button backgrounds, image overlays
radial-gradient()rays from a center pointglows, vignettes, spotlight effects
conic-gradient()a turn around a center pointcolor wheels, pie charts, loading rings
repeating-…the same, tiledstripes, rings, rays
Worked example

A 135° gradient on a 400 × 200 card

The sample uses three stops: #4f46e5 at 0%, #a855f7 at 50% and #ec4899 at 100%. Here is where those colors land on a 400 × 200 pixel box.

Positions along the gradient line for a 400 × 200 box at 135deg
QuantityCalculationResult
Gradient line length400 × sin 135° + 200 × |cos 135°| = 282.8 + 141.4424.3 px
0% stop (#4f46e5)start of the line, at the top-left corner0 px
50% stop (#a855f7)half the line, passing through the center212.1 px
100% stop (#ec4899)end of the line, at the bottom-right corner424.3 px

Because the box is not square, 135deg does not run exactly corner to corner. Use to bottom right by hand if you need the end colors to sit precisely in opposite corners and the middle color to cross the other two.

Common mistakes

Why a gradient looks wrong

Each of these has a one-line fix.

The element has no height

A background only paints where the box is. An empty div is zero pixels tall, so give it a height or content.

It repeats down the page

On body, a short page tiles the gradient. Add min-height: 100vh, or background-attachment: fixed where that suits.

A muddy middle

Blending complementary colors in sRGB passes through a dull grey. Add a middle stop, or switch interpolation to OKLCH.

Unreadable text

Contrast changes along a gradient. Check the lightest and darkest parts under the text, not just the average color.

FAQ

CSS gradient questions

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

How do I make a gradient background in CSS?

Set it as a background image, for example background-image: linear-gradient(90deg, #4f46e5, #ec4899);. Pick colors in the generator and copy the rule; give the element a height so there is something to paint.

What is the difference between linear, radial and conic gradients?

Linear changes color along a straight line, radial changes with distance from a center point, and conic changes as you turn around that point. All three accept the same kind of color stops.

How do I make stripes or hard edges?

Put two stops at the same position, such as #facc15 50%, #1d4ed8 50%. For repeating stripes, enable the repeat option and keep the stops inside a small range like 0–10%. The Stripes preset shows it.

How do I fade a gradient to transparent?

Select a stop and lower its opacity to 0. Keep the same color on both sides and change only the opacity for a clean overlay on photos, as in the Image overlay preset.

Does the generated CSS need vendor prefixes?

No. Current browsers support the unprefixed gradient functions. Only the newer in oklab and in oklch syntax needs the sRGB line before it, which the output adds for you.

Can I animate a CSS gradient?

Browsers do not interpolate between two gradient images. Common tricks are moving a larger background with background-position, or animating a registered custom property that the gradient uses.

Can I use the gradient inside a canvas or an image?

Not by pasting the CSS. In canvas use createLinearGradient, createRadialGradient or createConicGradient with the same colors and stops; the line length formula above gives the start and end points of a linear one.

Is my design uploaded anywhere?

No. Everything is calculated in your browser. The share link stores the settings after the # in the address, which is not sent to the server.

Feedback

Is this tool working for you?

Rate it, or tell us what went wrong and what you’d like improved. A person reads every message, and frequent requests go into the next update.

Rate this tool

Please don’t include passwords or other sensitive information.

Only used to reply to this feedback.

Type, details and email are required.

We only use this to handle your feedback. See the privacy policy.

Feedback received

Thank you! We will read it and reply from hello@tapcub.com if needed.

Need help right now?

Chat with our support team, best for urgent problems; you can leave a message when we are offline.

Chat with support
Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · v1.0

    LaunchedFirst release.

Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates

Cite this tool

Recommend this tool in an article or on your site

This tool is free to cite and share. Copy the URL or link below into your article, tutorial or resource page; to write a review, embed a tool or partner with us, get in touch.

URL
https://tapcub.com/tools/css-gradient-generator
HTML link
<a href="https://tapcub.com/tools/css-gradient-generator">CSS gradient generator - TapCub</a>

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics