CSS Gradient Generator

Inputs

Drag a marker to move its color; click the bar to add a color there.

    0 goes up, 90 to the right.

    0 is the left edge.

    0 is the top edge.

    How the in-between colors are mixed.

    Results

    CSS

    
      

    The same colors, three ways

    • OKLab
    • OKLCH
    • sRGB

    sRGB mixes the red, green and blue numbers directly, which can dip into gray between opposite colors.

    A CSS gradient blends between colors, and how it blends matters. Mixing the red, green and blue values directly (sRGB, what browsers did for years) can make the middle of a blue-to-yellow gradient a dull gray. Mixing in OKLab, a space built around how people see color, keeps it clean, and every current browser supports it.

    How to use it

    1. Set the colors (type them or use the pickers); add up to six. Drag the markers on the bar to move a color, or click the bar to add one in between.
    2. Pick the shape and the angle. Drag a color’s grip (⠿) to change the order. For radial and conic gradients, drag on the preview to move the center.
    3. Choose how to blend, compare the three strips, and copy the CSS.

    Example: blue #0047ab to gold #ffd700 in sRGB passes through a muddy gray in the middle; in OKLab the middle stays a clear color. The CSS is linear-gradient(in oklab 90deg, #0047ab, #ffd700), with a plain line before it for older browsers. Offset: with blue at 30% and gold at 70%, the first 30% is solid blue and the last 30% solid gold: linear-gradient(in oklab 90deg, #0047ab 30%, #ffd700 70%). Off-center: a radial gradient with its center at 25% across, 25% down is radial-gradient(circle at 25% 25% in oklab, …), like light from the top left.

    Questions and answers

    Do browsers support "in oklab"?

    Yes: current Chrome, Edge, Firefox and Safari all support color spaces in gradients. The CSS here also includes a plain sRGB line first, which older browsers use instead.

    OKLab or OKLCH?

    OKLab blends in a straight line between the colors: smooth and natural. OKLCH travels around the hue wheel, so red to blue passes through purple and pink at full strength: more vivid, sometimes surprising.

    How do I make a hard stripe instead of a blend?

    Put two colors at the same position: drag one marker onto the other, or type the same number in both position boxes. The CSS then reads like linear-gradient(90deg, red 50%, blue 50%).

    Link with pre-filled values

    Add # and these parameters to the end of this page's address to open the tool with values already filled in.

    ParameterWhat it sets
    colors2 to 6 colors, separated by commas, each optionally followed by its position from 0 to 100 (write # as %23 and the space as %20 in a link).
    typelinear, radial or conic.
    angleAngle in degrees (linear and conic).
    spaceBlend in oklab, oklch or srgb.
    xCenter of a radial or conic gradient, across, from 0 (left) to 100 (right).
    yCenter of a radial or conic gradient, down, from 0 (top) to 100 (bottom).

    Example: https://toolabelle.com/gradient-generator/#colors=%23ff7e5f+20%2C%23feb47b+80&type=linear&angle=135&space=oklab&x=25&y=25

    Related tools