Design

HEX, RGB, HSL, Gradients, and WCAG Contrast: A Frontend Color Workflow

Convert colors between HEX, RGB, and HSL, build CSS gradients you can paste, and check contrast against WCAG AA/AAA before the design review does.

Nikhil Sai··3 min read
All posts

Frontend color work fails in three predictable places: the design file says #0F172A, the CSS ends up rgb(15, 23, 42), the gradient stops don't match either, and the text contrast only looks fine on your calibrated monitor. You don't need a full design system to avoid that — you need a tight convert → compose → verify loop.

Speak every color format

HEX is compact and ubiquitous in design tools. RGB is what browsers compute. HSL is what humans reach for when they say "make it a bit lighter" without changing the hue. Converting between them shouldn't require opening three tabs and hoping the rounding matches.

A Color Converter that shows HEX, RGB, and HSL together (with a live swatch) keeps tokens consistent when you're translating Figma specs into CSS variables.

Gradients are just stops + an angle (until they aren't)

Linear and radial gradients look simple in a generator and verbose in CSS. The failure mode is hand-editing linear-gradient(135deg, ...) until the mid-stop drifts from the brand palette. Build the gradient visually from colors you already converted, then copy the CSS once.

A CSS Gradient Generator is the right tool when the artifact you need is paste-ready stylesheet code, not a PNG export from a design canvas.

Contrast is not optional decoration

WCAG contrast ratios exist because "looks fine to me" is not an accessibility strategy. Body text generally needs AA (4.5:1); large text can pass at 3:1; AAA is stricter still. Dark themes make this worse: muted gray on near-black fails constantly, and brand accents on colored backgrounds fail silently in components.

A Color Contrast Checker against AA/AAA thresholds should be part of token definition — not a last-minute QA surprise.

A workflow that sticks

  1. Pull the brand HEX from design
  2. Convert to RGB/HSL for CSS variables and adjustments
  3. Build gradients from those tokens
  4. Check foreground/background pairs for text, icons, and focus rings
  5. Re-check after dark-mode overrides

If you're also generating placeholder copy for layout mocks, a Lorem Ipsum Generator keeps the visual pass focused on color and type, not on inventing sample sentences.

Quick reference

  • Design handoff → convert HEX ↔ RGB ↔ HSL once; store as CSS variables
  • Marketing hero / cards → generate gradients from the same tokens
  • Text and UI chrome → verify contrast for light and dark themes
  • Don't pick accent colors solely by vibe — check the ratio on the actual background

Color tools are pure client-side transforms. There's no reason your brand palette should be uploaded anywhere just to get a contrast ratio.

Try these next