Color for AI Coders | SheCodes
Beginner 12 min read

Color Guide for AI Coders

Understand how colors work in web development. Learn the formats, explore palettes, and communicate colors precisely to AI. Try our Palette Generator to create a palette in seconds.

In this chapter

  • Hex, RGB, and HSL explained without the jargon
  • How to pick a palette that doesn't look amateur
  • How to describe colors precisely to your AI tool
  • Where to find ready-made palettes and gradients

Color Formats Explained

Live example

Hexadecimal (Hex)

#5046E5

Format: #RRGGBB

6 characters (0-9, A-F). Each pair = Red, Green, Blue.

Most Common

RGB / RGBA

rgb(80, 70, 229)

Format: rgb(R, G, B)

Values 0-255. RGBA adds alpha (0-1) for transparency.

With Transparency

HSL / HSLA

hsl(244, 75%, 59%)

Format: hsl(H, S%, L%)

Hue (0-360), Saturation (0-100%), Lightness (0-100%). Most human-readable.

Human Readable

Color Converter

Live example

Pick a color

HEX#5046E5
RGBrgb(80, 70, 229)
RGBArgba(80, 70, 229, 1)
HSLhsl(244, 75%, 59%)
HEX#F472B6
RGBrgb(244, 114, 182)
RGBArgba(244, 114, 182, 1)
HSLhsl(329, 86%, 70%)
HEX#2DD4BF
RGBrgb(45, 212, 191)
RGBArgba(45, 212, 191, 1)
HSLhsl(172, 66%, 50%)
HEX#10B981
RGBrgb(16, 185, 129)
RGBArgba(16, 185, 129, 1)
HSLhsl(160, 84%, 39%)
HEX#FBBF24
RGBrgb(251, 191, 36)
RGBArgba(251, 191, 36, 1)
HSLhsl(43, 96%, 56%)
HEX#FB923C
RGBrgb(251, 146, 60)
RGBArgba(251, 146, 60, 1)
HSLhsl(27, 96%, 61%)
HEX#38BDF8
RGBrgb(56, 189, 248)
RGBArgba(56, 189, 248, 1)
HSLhsl(198, 93%, 60%)
HEX#1A1A3E
RGBrgb(26, 26, 62)
RGBArgba(26, 26, 62, 1)
HSLhsl(240, 41%, 17%)

Transparency (Alpha Channel)

Live example
1
0.8
0.6
0.4
0.2
0.05

Common Web Colors

Click any swatch to copy its hex value.

Pinks & Reds

Bubblegum #F472B6
Hot Pink #EC4899
Rose #FB7185
Coral #FF6B6B

Purples

Lavender #A78BFA
Indigo #5046E5
Violet #7C3AED
Amethyst #9B59B6

Blues & Teals

Sky Blue #38BDF8
Ocean #3B82F6
Teal #2DD4BF
Turquoise #14B8A6

Greens

Mint #34D399
Emerald #10B981
Sage #6EE7B7
Forest #059669

Yellows & Oranges

Sunshine #FBBF24
Amber #F59E0B
Peach #FDBA74
Tangerine #FB923C

Neutrals

White #FFFFFF
Light Gray #F3F4F6
Gray #6B7280
Dark Navy #1A1A3E

Gradients

Smooth transitions between colors, popular for backgrounds, buttons, and hero sections.

Live example

Indigo → Pink

linear-gradient(135deg, #5046E5, #F472B6)

Teal → Indigo

linear-gradient(135deg, #2DD4BF, #5046E5)

Pink → Yellow

linear-gradient(135deg, #F472B6, #FBBF24)

Green → Blue

linear-gradient(135deg, #10B981, #38BDF8)

Orange → Indigo

linear-gradient(135deg, #FB923C, #5046E5)

Hot Pink → Teal

linear-gradient(135deg, #EC4899, #2DD4BF)

Try It: Live Color Preview

Pick colors below and see them applied to a real UI component instantly.

Live example
Brand Color
Background
Text Color
My App
HomeAboutContact

Welcome to My Site

This is a live preview. Change the colors above to see how they look together.

Get Started

Color Roles in Web Design

Primary Main brand color. Buttons, links, key elements.
Accent / Secondary Complements primary. Highlights, visual interest.
Success Green: confirmations, positive indicators.
Warning Yellow/amber: cautions, needs attention.
Danger / Error Red: errors, destructive actions.
Neutral Grays for text, borders, backgrounds.

Contrast & Accessibility

Good contrast (4.5:1 minimum for normal text) is essential for readability.

Live example
Good Contrast

White text on dark background is easy to read.

Good Contrast

Dark text on light background: the classic approach.

Low Contrast

Light gray on medium gray is harder to read.

Bad Contrast

Dark text on medium purple fails accessibility standards.

Gradient Types

Gradients blend two or more colors together. There are three main types, each creating a different visual effect. Try our Gradient Generator to build your own.

Linear Gradients

Colors flow in a straight line: left to right, top to bottom, or at any angle you choose. Think of paint rolling across a wall in one direction.

Live example

Left → Right

linear-gradient(to right, #5046E5, #F472B6)

Top → Bottom

linear-gradient(to bottom, #2DD4BF, #5046E5)

Diagonal (135°)

linear-gradient(135deg, #FB923C, #EC4899)

3 Colors

linear-gradient(90deg, #10B981, #38BDF8, #5046E5)

Radial Gradients

Colors radiate outward from a center point, like ripples in a pond. Great for spotlight effects and glowing backgrounds.

Live example

Circle

radial-gradient(circle, #5046E5, #1A1A3E)

Ellipse

radial-gradient(ellipse, #F472B6, #5046E5)

From Corner

radial-gradient(circle at top left, #FBBF24, #FB923C, #EC4899)

3 Color Stops

radial-gradient(circle, #2DD4BF 0%, #5046E5 50%, #1A1A3E 100%)

Conic Gradients

Colors sweep around a center point like the hands of a clock. Perfect for pie charts, color wheels, and creative backgrounds.

Live example

Simple Sweep

conic-gradient(#5046E5, #F472B6, #5046E5)

Rainbow

conic-gradient(from 90deg, #FBBF24, #FB923C, #EC4899, #5046E5, #FBBF24)

Pie Chart

conic-gradient(#2DD4BF 0% 33%, #5046E5 33% 66%, #F472B6 66% 100%)

Rotated Start

conic-gradient(from 45deg, #1A1A3E, #5046E5, #F472B6, #FBBF24, #1A1A3E)

Color Contrast & Accessibility

Accessibility means everyone can use your site, including people with vision impairments. The key rule: text must be easy to read against its background. This is measured as a contrast ratio. See our Accessibility guide for the full picture.

Live example

WCAG Contrast Requirements

WCAG (Web Content Accessibility Guidelines) is the international standard. Here are the minimum ratios:

Normal Text

4.5 : 1 minimum

Body text, labels, captions. Anything under 24px (or under about 19px bold).

Large Text

3 : 1 minimum

Headings and large text, 24px or larger (or about 19px bold and larger).

Good vs. Bad Contrast Examples

Live example
Passes (12.6 : 1)

Dark text on white

Easy to read for everyone.

Fails (1.3 : 1)

Light text on yellow

Nearly invisible. Never do this.

Passes (6.3 : 1)

Blue on dark navy

Bright colors can work on dark backgrounds.

Fails (1.9 : 1)

Gray on light gray

Looks modern but unreadable.

Dark Mode Color Strategies

Dark mode flips your site to light text on dark backgrounds. It reduces eye strain at night, saves battery on OLED screens, and many users simply prefer it. For the full implementation walkthrough, see our dark mode guide. But you can't just invert your colors. It takes a bit more thought.

Key Tips for Dark Mode

  • Don't use pure black. Use a dark gray like #1A1A2E or #121212 instead of #000000. Pure black feels harsh and creates too much contrast with white text.
  • Reduce color saturation. Bright, saturated colors that look great on white can feel neon and glaring on dark backgrounds. Tone them down slightly.
  • Increase text opacity slightly. Instead of pure white (#FFFFFF) for body text, use a slightly muted white like #E5E7EB. It's gentler on the eyes.
  • Keep sufficient contrast. Dark mode still needs to meet the 4.5:1 contrast ratio. Test your dark mode colors just like you'd test light mode.

Light vs. Dark Comparison

Live example
Light Mode

Welcome Back

Here's what happened while you were away.

Primary Secondary
Dark Mode

Welcome Back

Here's what happened while you were away.

Primary Secondary

Color Psychology

Colors trigger emotions and associations. Choosing the right colors for your project isn't just about looks. It's about how your site makes people feel.

Red Urgency, passion, energy
Sales, alerts, food apps
Blue Trust, calm, reliability
Finance, healthcare, tech
Green Growth, success, nature
Eco brands, finance, health
Purple Creativity, luxury, wisdom
Beauty, education, premium
Orange Energy, warmth, friendliness
Fitness, kids, CTAs
Yellow Optimism, attention, joy
Warnings, highlights, playful
Pink Playful, feminine, modern
Fashion, dating, lifestyle
Black Elegant, serious, powerful
Luxury, portfolio, editorial

Prompt This

Copy-paste these prompts into your AI tool to apply what you just learned.

CREATE A COLOR PALETTE

“Create a color palette for my [type of app] using a [mood/vibe] feel. Include primary, secondary, accent, background, and text colors as CSS variables. Give me both light and dark mode versions.”

ADD A CONSISTENT COLOR SYSTEM

“Add a consistent color system to my app. Use [primary color] as the brand color and generate complementary colors for backgrounds, borders, text, and hover states. Define them as CSS variables so I can change them in one place.”

FIX COLOR CONTRAST

“Review my color choices for accessibility. Make sure all text has at least 4.5:1 contrast against its background. Suggest fixes for any colors that fail, keeping the same general vibe.”

Frequently Asked Questions

How many colors should my site use?

Start with 3-5 colors: a primary brand color, a secondary accent, a background color, a text color, and one for borders/dividers. You can add shades (lighter/darker versions) of these but avoid introducing entirely new colors without purpose.

How do I pick colors that look good together?

Use a color palette generator (like the one on this site). Start with one color you like, then generate complementary colors. Or copy the palette from a site you admire. You don't need to be a designer. Tools do the hard work.

What is color contrast and why does it matter?

Contrast is the difference in brightness between text and its background. Low contrast (like light gray text on white) is hard to read, especially for people with vision impairments. Aim for a minimum 4.5:1 contrast ratio. Your AI tool can check this for you.