Skip to content
CertoflowCertoflow
Color Tools

CSS Gradient Generator

Generate linear-gradient CSS.

Last updated: June 2026

Swatch
Swatch
Swatch

background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);

Guide

Introduction

CSS gradients transform flat backgrounds into depth, brand energy, and visual hierarchy — but authoring linear-gradient() syntax from memory invites errors. Wrong angle units, misplaced color stops, and missing vendor fallbacks produce broken heroes and inconsistent button fills. Designers hand you three hex swatches and a Figma angle; you need copy-paste-ready CSS without opening a desktop gradient editor.

Certoflow's CSS Gradient Generator builds linear-gradient(angle, color-stops) declarations from two or three hex colors with an adjustable angle slider and live preview. Generation runs entirely in your browser — brand gradient definitions stay private. Light and dark theme support keeps previews and code output readable during stylesheet work.

What this tool does

FeatureBehavior
Color stopsTwo or three hex colors
Angle0–360 degrees (CSS deg syntax)
OutputComplete linear-gradient(...) string
PreviewLive gradient swatch
CopyOne-click CSS clipboard export

Output is ready for background, background-image, or CSS custom properties.

How it works

Certoflow distributes color stops evenly along the gradient line:

  • Two colors: 0% and 100%
  • Three colors: 0%, 50%, 100%
function buildLinearGradient(colors, angle = 90) {
  const stops = colors.map((c, i) => {
    const pct = colors.length === 2
      ? (i === 0 ? "0%" : "100%")
      : `${Math.round((i / (colors.length - 1)) * 100)}%`;
    return `${c} ${pct}`;
  });
  return `linear-gradient(${angle}deg, ${stops.join(", ")})`;
}

Angle follows CSS convention: 0deg points upward, 90deg points right, 180deg points downward, 270deg points left. The preview renders the gradient on a div using the generated CSS string.

All processing is local JavaScript. No gradient definitions transmit to Certoflow servers.

Example output:

linear-gradient(135deg, #2563eb 0%, #7c3aed 100%)
linear-gradient(90deg, #f59e0b 0%, #ef4444 50%, #8b5cf6 100%)

Real-world examples

Hero section background

Marketing wants blue-to-purple at 135 degrees. Enter #2563eb and #7c3aed, set angle 135, copy output:

.hero {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}

Format with CSS Formatter before committing.

Button fill with mid-stop highlight

Three-stop gradient simulates light source: dark base #1d4ed8, mid #3b82f6, highlight #60a5fa at 90 degrees for horizontal buttons.

Complementary pair gradients

Generate complement with Complementary Color Generator, use both hex values as gradient stops for high-energy CTAs. Validate text contrast separately with Color Contrast Checker.

Prototyping from random colors

Random Color Generator produces experimental hex values. Feed two into the gradient generator for wireframe backgrounds before brand tokens finalize.

Design system documentation

Document standard gradient tokens alongside flat colors. Copy Certoflow output into JSON design tokens for background.gradient.primary.

Common mistakes

Confusing CSS angle with design tool angle. Some tools measure angles differently. Verify visually with the live preview and nudge degrees until matched.

Expecting radial gradients. This tool generates linear-gradient only. Radial and conic gradients require different CSS syntax.

Using too many stops in this version. Up to three evenly spaced stops are supported. Complex multi-stop gradients need manual CSS editing after initial generation.

Forgetting fallback solid color. Older browsers without gradient support benefit from a solid background-color fallback matching the gradient's average or start color.

Placing low-contrast text on gradients. Contrast varies across the gradient surface. Test text against the lightest and darkest regions with Color Contrast Checker.

Omitting background-repeat: no-repeat. Gradients on small elements may tile unexpectedly without explicit sizing or no-repeat.

Hardcoding without CSS variables. For themeable gradients, wrap colors in custom properties and regenerate when tokens change.

Related tools

Color category:

Cross-category:

Directory at /color.

FAQ

Is gradient data uploaded?

No. CSS string generation runs locally.

Radial gradient support?

Not in this version. Linear gradients only.

Maximum color stops?

Two or three colors with even spacing.

What angle units?

CSS degrees (deg). 0deg is bottom-to-top; 90deg is left-to-right.

Can I use hsl() stops?

Enter hex colors. Convert hsl to hex with HSL to Hex first.

Copy includes background: prefix?

Output is the linear-gradient(...) function value. Wrap in background: or background-image: as needed.

Offline?

Yes, after page load.

Dark mode?

Certoflow UI supports light and dark themes. Preview shows the gradient independently of UI chrome.

Vendor prefixes?

Modern browsers do not require -webkit-linear-gradient for standard syntax. Add prefixes manually only if targeting legacy browsers.

How do I match a Figma gradient?

Match hex stops and adjust angle using the preview until visual alignment is close. Figma may use different stop positions — manual refinement may be needed.

Can I use gradients with dark mode themes?

Yes. Generate separate gradient tokens for light and dark surfaces, or swap stop hex values when your stylesheet applies a prefers-color-scheme media query.

Frequently Asked Questions

Radial gradients?
This tool generates linear-gradient. Radial support may come in a future update.
Can I use more than three colors?
Up to three color stops in this version with even spacing.

Related tools that complement this workflow.