Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
TroubleshootingNovember 22, 20265 min read

Dark mode problems and fixes

Most dark mode bugs come from colors written directly into components instead of theme tokens, and from the theme being decided too late on load.

Startbase Team
Editorial ink illustration of a desk lamp lighting half of an open notebook while a white sticky note glares in the shadow, the bulb in ember orange

Key takeaways

  • Unreadable text in dark mode almost always means a color was hard-coded instead of coming from a theme token.
  • The white flash on load happens because the theme is applied after the page paints; set it before the first paint.
  • A toggle needs three states (light, dark, system) and must save the choice and apply it on every page.
  • Images, logos, charts, inputs and third-party widgets need their own dark treatment.

Dark mode problems, like black text on a dark background, white cards glaring in a dark page, or a white flash before the dark theme appears, almost always come from two causes. First, colors are written directly into components (a white background here, a gray text there) instead of using theme tokens that switch together. Second, the theme is decided too late: the page paints in light colors, then JavaScript reads the saved preference and flips it. Fix the tokens and apply the theme before the first paint, and most of the remaining bugs are edge cases like logos and form fields.

Match your symptom

  • Some text disappears in dark mode: a hard-coded dark text color on a surface that now turns dark. Cause 1.
  • A bright white box in an otherwise dark page: a hard-coded white background, often a card, modal, dropdown or input. Cause 1.
  • White flash for a split second on every load or page change: theme applied after paint. Cause 2.
  • The toggle works, then resets on refresh or on another page: the choice is not saved, or is read too late. Cause 3.
  • Dark mode turns on when nobody asked: the app follows the phone setting and you expected light by default. Cause 3.
  • A black logo vanishes, or charts become unreadable: images and canvases do not follow CSS colors. Cause 4.
  • Form fields, scrollbars or date pickers stay light: the browser was not told the page is dark. Cause 5.

Causes, most likely first

1. Hard-coded colors instead of tokens

A working dark mode is a set of named colors (background, surface, text, muted text, border, accent) defined once for light and once for dark. Components use only the names. When the theme switches, everything moves together. AI-built screens drift from this when a later request says "make this card white" and the code writes white directly. In Tailwind projects, the tell is a light class with no dark variant, such as a bg-white with no matching dark: class, or text-gray-900 on a component used on both surfaces.

Check: search the code for literal colors: hex codes, rgb(), bg-white, text-black, gray scales. Any that appear in components rather than in the theme file are suspects. Fix: replace them with tokens, or add the matching dark variant. Startbase web apps use Tailwind, and the docs' own example prompt for this asks to use the existing dark: variants and add dark equivalents without changing the palette (agent docs). Expo apps in Startbase start with light and dark theme tokens in theme/tokens.ts, so the whole app restyles from one place (Expo template).

2. The theme is applied after the first paint

React renders, the browser paints the default light styles, then an effect reads localStorage and adds the dark class. That gap is the flash, and it repeats on every full page load. Fix: put a tiny inline script in the head of index.html that reads the saved choice (or the system preference if there is none) and sets the dark class or a data-theme attribute on the html element before anything renders. Also give the html and body elements the dark background directly, so even the first blank frame is dark.

3. The preference is not stored, or there is no "system" option

Good toggles have three states: light, dark and system (follow the device). Store the choice in localStorage (or in the user's profile if they sign in on several devices), read it in the head script above, and listen for system changes when the choice is "system", so the app switches at sunset along with the phone. Check: set dark, refresh, open another page, close and reopen the tab. Then set system and flip your device setting. Fix: one theme provider at the root that owns the value; no page should read it on its own.

4. Images, logos, icons and charts

CSS colors do not reach inside a PNG. A black logo on a transparent background disappears on dark. Options, in order of preference: an SVG logo that uses currentColor, so it follows the text color; two image files swapped by theme (the picture element can choose by prefers-color-scheme); or a subtle light plate behind the logo. Chart libraries and game canvases draw with their own colors, so pass theme colors in explicitly and re-render when the theme changes. Photos usually look fine; slightly lowering their brightness in dark mode reduces glare.

5. Native controls and third-party widgets

Inputs, checkboxes, scrollbars and date pickers use browser defaults. Set the CSS color-scheme property to "light dark" (or to "dark" when the dark theme is active) so the browser draws dark versions. Embedded widgets such as payment forms, maps and calendars often accept a theme or appearance option; set it from the same theme value.

6. Mobile apps: status bar and system color scheme

In an Expo app the same rules apply with different names. Read the device setting with useColorScheme, pick colors from the theme tokens, and never write a color into a style object directly. Two extra traps: the status bar keeps dark icons on a dark screen unless you switch its style with the theme, and the app config may lock the interface to light, so the phone setting is ignored. Test both themes on a real phone through Expo Go, since the device frame in a browser does not always reflect the phone setting.

Dark mode that looks designed, not inverted

  • Avoid pure black backgrounds with pure white text. The contrast is harsh; a very dark gray background and an off-white text read better.
  • Keep contrast at WCAG levels: at least 4.5:1 for body text and 3:1 for large text. Muted gray text is where dark themes fail most often (accessibility glossary entry).
  • Show depth with lighter surfaces, not shadows. Shadows barely show on dark; a card one step lighter than the background does the job.
  • Desaturate the accent a little. Strong colors that look fine on white can vibrate on dark.

The message to send the agent

Dark mode has three problems: the order summary card stays white, the muted labels in the settings page are almost invisible, and every page flashes white before turning dark. Replace hard-coded colors in components with the theme tokens (or add the matching dark: variants), check every text color meets 4.5:1 contrast on its background in both themes, and set the saved theme in an inline script in the head of index.html before the first paint, with light, dark and system options saved in localStorage. Set color-scheme so inputs and scrollbars follow. Do not change the light theme.

Then check it yourself: switch the preview to Phone and Desktop views, flip the theme on every main screen, and use Draw on the preview to circle anything still wrong and send it back to chat (preview docs). A screenshot of the broken spot beats a paragraph of description.

Frequently asked questions

How do I stop the white flash when my site loads in dark mode?

Apply the theme before the page paints. A small inline script in the head reads the saved choice or the system preference and sets the dark class on the html element, and the html background itself is set to the dark color.

Why is some of my text invisible in dark mode?

Those elements have a hard-coded dark text color, or sit on a background that switched while the text did not. Use theme tokens for both, or add a dark variant to that class.

Should my app follow the phone's dark mode setting?

Default to the system setting, and let people override it with light or dark. Save the override so it sticks across visits and pages.

How do I make my logo work in dark mode?

Use an SVG logo that inherits the text color, or provide a second version for dark backgrounds and switch it with the theme. A black PNG on a transparent background will disappear.

On this page

  • Match your symptom
  • Causes, most likely first
  • Dark mode that looks designed, not inverted
  • The message to send the agent

Keep reading

More in Troubleshooting
Editorial ink illustration of an overstuffed card catalog drawer spilling index cards, the brass tab of one card in ember orange
TroubleshootingNovember 22, 2026

Why is my app slow with lots of data?

An app that slows down as data grows almost always loads or draws too much at once. Here is how to find which part is slow and the fix for each.

6 min read
Editorial ink illustration of a border checkpoint with a lowered barrier arm and a waiting parcel, the guard's stamp in ember orange
TroubleshootingNovember 22, 2026

CORS errors explained and fixed

A CORS error means the server you called did not say your website is allowed to read its answer. The fix lives on that server, or in a server function you control.

5 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.