A two-colour gradient is the most versatile and universally applicable form of CSS gradient.
Loading Gradient…
Generate a gradient between any two colours
Set direction and stop positions precisely
Outputs minimal, readable CSS gradient code
Works for backgrounds, buttons, borders, and text
Drop the Gradient into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/css-tool/gradient?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Gradient by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
Two-colour gradients are the foundation of CSS gradient design and the most appropriate gradient type for the majority of UI components. With only two stops, the transition is visually unambiguous: the eye reads a single directional colour shift from start to end without confusion. This simplicity is a feature, not a limitation. Buttons, badges, cards, and hero sections all benefit from the focused, clear colour shift of a two-stop gradient. More complex multi-stop gradients have their place in illustrative backgrounds and artistic compositions, but for functional UI components the two-stop form is almost always more appropriate because it does not compete with the content displayed on or within the element. The primary design decision for a two-stop gradient is the colour pairing. A well-chosen pair of adjacent or analogous hues produces a harmonious, professional-grade transition. Complementary or high-contrast pairs produce vibrance and visual energy, appropriate for call-to-action buttons and highlight elements.
The CSS syntax for a two-colour gradient is straightforward: background: linear-gradient(direction, color1 position1, color2 position2). Both position values are optional. Without explicit positions, the browser automatically places the first stop at 0% and the second at 100%, distributing the transition evenly across the full element. Specifying positions allows you to weight the gradient toward one colour: linear-gradient(to right, #667eea 30%, #764ba2 100%) extends the first colour solidly across the initial 30% of the element before the transition begins, making the first colour the dominant presence. For radial two-stop gradients, the equivalent form is background: radial-gradient(circle at center, color1 0%, color2 100%). The same position weighting principles apply, with the inner colour at 0% and the outer colour at 100%. Positions can also use pixel or rem values rather than percentages for precise control in fixed-dimension elements.
FixTools produces the two-stop gradient CSS directly from your colour inputs and direction or shape configuration. The output is a single, clean background declaration with no extra syntax or vendor prefixes. Copy it and apply it to any HTML element in your stylesheet, a CSS module, a Tailwind arbitrary value, or a CSS-in-JS template literal. No modification to the generated code is required before use.
Edge cases worth knowing about two-stop gradients revolve around extreme stop positioning and zero-distance transitions. When both stops sit at the same position (linear-gradient(to right, red 50%, blue 50%)), the result is a hard split with no blend at all, effectively producing a two-zone solid background using a single CSS declaration. When the first stop position is greater than the second (linear-gradient(to right, red 80%, blue 20%)), browsers handle the case by treating the second stop as if it sat at the first stop's position, producing the same hard-split result. When stops use mixed units (linear-gradient(to right, red 50px, blue 80%)), the percentage resolves against the gradient line length, so the visual result depends on element dimensions. For predictable behaviour across responsive layouts, prefer consistent units within a single gradient declaration. Negative stop positions are valid and useful when you want a colour to start outside the visible area.
Pick two colours and a direction. Example: background: linear-gradient(135deg, #667eea 0%, #764ba2 100%)
Step-by-step guide to two color gradient css:
Open the CSS Gradient Generator
Click "Open CSS Gradient Generator" to launch the editor. The visual interface gives you a live preview of the gradient as you configure each setting, so you can see the result immediately without switching between a code editor and a browser window.
Add exactly two colour stops
Set the first stop to your start colour and the second stop to your end colour. If the tool shows more than two stops by default, remove the extras. A two-stop gradient keeps the transition clean and easy to read on any element size from a small badge to a full-page hero section.
Set the direction
Choose an angle or directional keyword for the gradient transition. For horizontal gradients use 90deg or "to right"; for classic diagonal depth use 135deg; for vertical top-to-bottom use 180deg or "to bottom". The live preview updates immediately when you change the direction setting.
Copy the CSS output
Copy the single background: linear-gradient(...) declaration from the output panel. Paste it directly into your stylesheet, CSS module, or component. No modification to the generated code is needed before applying it to your element.
Common situations where this approach makes a real difference:
Primary call-to-action button
A checkout flow needs a prominent "Buy Now" button that stands out from the surrounding page content and communicates urgency and confidence. The developer generates a 90-degree left-to-right gradient from brand blue (#4facfe) to a slightly deeper cyan (#00f2fe), applies it as the button background with border-radius: 8px, padding: 14px 32px, and font-weight: 700. The gradient makes the button feel more three-dimensional and energetic than a flat colour, and a hover state uses a reversed 270-degree direction with a short transition for a satisfying interactive response.
Profile card header band
A user profile page displays a coloured header band at the top of each profile card to add visual personalisation. Rather than a flat solid colour that would look generic across many user cards, the designer generates a diagonal two-stop gradient from each user's assigned brand colour to a complementary lighter tint. Applied to the card header div at height: 80px, the gradient gives each card a feeling of individual identity and visual richness using only a single CSS background property change with no additional image requests.
Progress bar fill
A project management tool shows task completion as horizontal progress bars. Each bar uses a left-to-right two-stop gradient from a vivid start colour to a slightly lighter tint at the end stop, applied with background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%). The gradient transition from a more saturated start to a lighter end makes the filled portion feel dynamic and forward-moving rather than static and flat, and the visual progression toward lighter values subtly reinforces the concept of completion and progress.
Section alternating background
A portfolio site uses alternating page sections for rhythm and visual separation without harsh horizontal dividers. Odd sections use plain white; even sections use a subtle two-stop gradient from off-white (#fafafa) at the top to a pale blue-grey (#f0f4f8) at the bottom, applied with background: linear-gradient(180deg, #fafafa 0%, #f0f4f8 100%). The gentle directional colour shift creates a sense of visual depth and separates content areas clearly while maintaining a comfortable, low-contrast reading environment across the full page.
Use this when you need a simple, clean gradient between exactly two colours for a background, button, badge, or UI element.
Get better results with these expert suggestions:
Use analogous colours for calm, professional gradients
Analogous colour pairs, those adjacent on the colour wheel such as blue and purple or green and teal, produce smooth and harmonious transitions that read as refined and trustworthy in professional contexts. They are the most common choice for SaaS products, fintech dashboards, and corporate websites because the perceptual transition between analogous hues is naturally even and avoids the muddy midpoint that often appears when complementary pairs are blended in sRGB colour space at full saturation.
Shift lightness between stops for monochromatic depth
A monochromatic two-stop gradient uses the same hue at different lightness values: for example, from a lighter brand tint at the top to the full brand colour at the bottom. This technique adds genuine visual depth to backgrounds, buttons, and cards without introducing any secondary hue into the design. It is especially appropriate when strict brand colour consistency is required but a completely flat background would look static. The transition reads as lighting rather than colour change.
Use percentage positions to weight the dominant colour
Moving the second colour stop from 100% to 60% causes that colour to occupy a larger share of the element, with the transition zone compressed into the final 40%. For example, linear-gradient(to right, #667eea 0%, #764ba2 60%) gives the purple roughly two-thirds of the element width. Weighting gradients this way ensures your brand's dominant or most recognisable colour remains the primary visual presence on the element, even within a multi-colour gradient.
Test your two-stop gradient in dark mode
A vivid two-stop gradient that works well on a light background can appear harsh, fluorescent, or low-quality in dark mode because vivid saturated colours create excessive contrast against near-black backgrounds. For dark mode variants, shift both colour stops darker by reducing HSL lightness by 15 to 25 percentage points and reducing saturation by 10 to 20 points. Define both the light and dark variants as CSS custom property values and override them inside @media (prefers-color-scheme: dark) for automatic system-preference-aware switching.
More use-case guides for the same tool:
Open the full Gradient — free, no account needed, works on any device.
Open Gradient →Free · No account needed · Works on any device