Dark Mode for AI Coders | SheCodes
Intermediate 5 min read

Dark Mode for AI Coders

Give your users the option to switch between light and dark themes. It looks professional and is easier on the eyes.

In this chapter

  • Why so many users expect a dark mode option
  • How to pick dark mode colors that look professional
  • How to ask AI to add a working theme switcher
  • How to fix the white flash bug when your page loads

Why Add Dark Mode?

Dark mode is not just a trend. There are real benefits for your users and your site.

Reduces Eye Strain Easier on the eyes in low-light environments. Many people browse at night and prefer dark backgrounds.
Saves Battery On phones and laptops with OLED screens, dark mode uses significantly less battery because dark pixels use less power.
Looks Professional Having a dark mode toggle shows attention to detail. Users expect it on modern websites and apps.

Light vs Dark: Side by Side

The same UI rendered in light and dark mode. Notice how colors, borders, and text adapt while the layout stays identical.

Live example
Light Mode
MyApp
HomeAboutContact

Welcome back, Sarah

Here is a summary of your recent activity and upcoming tasks.

Project Update

3 new tasks assigned today

Dark Mode
MyApp
HomeAboutContact

Welcome back, Sarah

Here is a summary of your recent activity and upcoming tasks.

Project Update

3 new tasks assigned today

Common Mistakes: Visual Examples

Live example
Too Much Contrast

Pure black + white

Hard on the eyes

bg: #000 text: #FFF Bad

Dark gray + off-white

Much easier to read

bg: #1A1A2E text: #E4E4E7 Good
Forgotten Elements

Sign Up Form

••••••••

Don't forget form inputs! These still use light styles.

How to Ask Your AI Tool to Add It

Here are ready-to-use prompts for adding dark mode to your project. Copy the one that fits your situation.

Live example
Starting a new project
Use this when you are building a site from scratch and want dark mode from the beginning.

“Build me a portfolio website with both light and dark mode. Add a sun and moon toggle button in the header so people can switch between them. The light version should use a warm white background and the dark version should use a soft dark gray (not pure black) background. Make sure all the text, cards, and borders still look good when switching.”

Adding to an existing project
Use this when you already have a website and want to add dark mode support.

“Add dark mode to my existing website. Put a sun and moon toggle button in the navigation bar so people can switch between them. Pick dark colors that match my current design. Make sure every card and section still looks good in both versions. Do not use pure black. Use soft dark gray shades instead.”

Fixing dark mode issues
Use this when your dark mode exists but some parts do not look right.

“My dark mode has issues. Some cards and sections still show white backgrounds when I switch to dark mode. Please go through every part of the site and make sure all backgrounds, text colors, borders, and shadows look right in both light and dark mode. Also fix the flash of the wrong colors when the page first loads.”

Color Palette Tips

Getting the colors right is the most important part of dark mode. Here are the rules to follow.

Live example

Do This

Dark gray backgrounds

Use #1A1A2E or #121212 instead of pure black

Slightly muted white text

Use #E4E4E7 instead of pure white for body text

Elevated surface colors

Cards should be slightly lighter than the background

Subtle borders

Use dark gray borders, not invisible or too bright ones

Avoid This

Pure black backgrounds

#000000 is too harsh and creates too much contrast

Pure white text

#FFFFFF on dark backgrounds causes eye strain

Overly saturated colors

Bright neons on dark backgrounds are hard to read

Aa

Low contrast text

Text must still be readable. Check contrast ratios.

“Review my dark mode color palette. Make sure I am not using pure black or pure white. The background should be a dark gray, text should be slightly off-white, and cards should be a lighter shade than the background. Fix any contrast issues.”

Common Mistakes

Watch out for these issues when adding dark mode to your site.

Flash of wrong colors

The site briefly shows the wrong colors for a split second before switching. Just ask your AI tool to fix the flash on page load.

Forgetting images

Dark logos on dark backgrounds become invisible. Ask your AI tool to swap in a lighter logo when dark mode is on.

Colors stuck on light

Sometimes parts of the site stay white even after switching. Tell your AI tool to find every place that still uses light colors and fix them.

Ignoring shadows

Shadows that look great on white backgrounds become invisible in dark mode. Ask for lighter or glowing shadows when dark mode is on.

Not checking every page

It is easy to forget a page or section. Always flip between light and dark and check every page of your site.

Ignoring the user's device setting

Your site should match the light or dark setting on the visitor's phone or computer by default. Just ask your AI tool to make it match the device setting.

Prompt This

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

ADD A DARK MODE TOGGLE

“Add dark mode to my app with a sun and moon toggle button in the navigation bar. Switching should be instant. Start in whichever mode the visitor's device is already set to.”

GENERATE A DARK COLOR PALETTE

“Create a dark color palette for my app. The current light colors are [list colors]. Generate dark equivalents that maintain contrast and readability.”

What Good Dark Mode Should Do

When you ask your AI tool to add dark mode, make sure it covers these four things. If anything is missing, just ask for it.

No flash on load The page should never flash the wrong colors for a split second when it first opens.
Matches the device If the visitor already has their phone or computer set to dark mode, your site should start in dark mode too.
Remembers the choice Once someone picks light or dark, the site should remember it next time they come back.
Easy toggle button A clear sun and moon button in the navigation bar so anyone can switch with one click.

“Add dark mode to my website. Put a sun and moon toggle button in the navigation bar so people can switch with one click. Make the site start in dark mode if the visitor's device is already set to dark mode, and remember their choice next time they visit. Make sure the page never flashes the wrong colors when it first loads.”

Frequently Asked Questions

Should I add dark mode to my site?

If your site will be used for long reading or work sessions, yes. People increasingly expect it. For simple landing pages or marketing sites, it is nice to have but not essential. The good news: you can just ask your AI tool to add it for you.

What colors should I use for dark mode?

Do not just flip everything. Use dark grays (not pure black) for backgrounds, slightly muted whites for text, and keep your brand colors but tone down their brightness. A good starting point: background #0F0E17, cards #1A1A2E, text #E5E5E5.

My dark mode flashes white when the page loads. How do I fix that?

This is a common bug: the page shows the wrong colors for a split second before switching. Just tell your AI tool: 'Fix the flash of the wrong colors when my page first loads.' It will know what to do.