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
Hexadecimal (Hex)
#5046E5
Format: #RRGGBB
6 characters (0-9, A-F). Each pair = Red, Green, Blue.
Most CommonRGB / RGBA
rgb(80, 70, 229)
Format: rgb(R, G, B)
Values 0-255. RGBA adds alpha (0-1) for transparency.
With TransparencyHSL / HSLA
hsl(244, 75%, 59%)
Format: hsl(H, S%, L%)
Hue (0-360), Saturation (0-100%), Lightness (0-100%). Most human-readable.
Human ReadableColor Converter
Pick a color
#5046E5rgb(80, 70, 229)rgba(80, 70, 229, 1)hsl(244, 75%, 59%)#F472B6rgb(244, 114, 182)rgba(244, 114, 182, 1)hsl(329, 86%, 70%)#2DD4BFrgb(45, 212, 191)rgba(45, 212, 191, 1)hsl(172, 66%, 50%)#10B981rgb(16, 185, 129)rgba(16, 185, 129, 1)hsl(160, 84%, 39%)#FBBF24rgb(251, 191, 36)rgba(251, 191, 36, 1)hsl(43, 96%, 56%)#FB923Crgb(251, 146, 60)rgba(251, 146, 60, 1)hsl(27, 96%, 61%)#38BDF8rgb(56, 189, 248)rgba(56, 189, 248, 1)hsl(198, 93%, 60%)#1A1A3Ergb(26, 26, 62)rgba(26, 26, 62, 1)hsl(240, 41%, 17%)Transparency (Alpha Channel)
Common Web Colors
Click any swatch to copy its hex value.
Pinks & Reds
#F472B6
#EC4899
#FB7185
#FF6B6B
Purples
#A78BFA
#5046E5
#7C3AED
#9B59B6
Blues & Teals
#38BDF8
#3B82F6
#2DD4BF
#14B8A6
Greens
#34D399
#10B981
#6EE7B7
#059669
Yellows & Oranges
#FBBF24
#F59E0B
#FDBA74
#FB923C
Neutrals
#FFFFFF
#F3F4F6
#6B7280
#1A1A3E
Gradients
Smooth transitions between colors, popular for backgrounds, buttons, and hero sections.
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.
Welcome to My Site
This is a live preview. Change the colors above to see how they look together.
Get StartedColor Roles in Web Design
Contrast & Accessibility
Good contrast (4.5:1 minimum for normal text) is essential for readability.
White text on dark background is easy to read.
Dark text on light background: the classic approach.
Light gray on medium gray is harder to read.
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.
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.
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.
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.
WCAG Contrast Requirements
WCAG (Web Content Accessibility Guidelines) is the international standard. Here are the minimum ratios:
4.5 : 1 minimum
Body text, labels, captions. Anything under 24px (or under about 19px bold).
3 : 1 minimum
Headings and large text, 24px or larger (or about 19px bold and larger).
Good vs. Bad Contrast Examples
Dark text on white
Easy to read for everyone.
Light text on yellow
Nearly invisible. Never do this.
Blue on dark navy
Bright colors can work on dark backgrounds.
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
Welcome Back
Here's what happened while you were away.
Welcome Back
Here's what happened while you were away.
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.
Sales, alerts, food apps
Finance, healthcare, tech
Eco brands, finance, health
Beauty, education, premium
Fitness, kids, CTAs
Warnings, highlights, playful
Fashion, dating, lifestyle
Luxury, portfolio, editorial
Prompt This
Copy-paste these prompts into your AI tool to apply what you just learned.
“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 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.”
“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.