How do I add dark mode?
Last checked 31 Aug 2026
Short answer
Ask Lovable to add a theme toggle using Tailwind's dark mode classes and shadcn/ui's theming support, then check every page and component — including third-party embeds — for readable contrast in both themes.
How Lovable typically implements it
Tailwind supports dark mode via a dark: variant, and shadcn/ui components are built with CSS variables that make theme switching straightforward. Ask for the whole system, not just a toggle:
Add a light/dark mode toggle in the header. Use Tailwind's dark mode classes and the existing shadcn theme variables so all components (buttons, cards, inputs) adapt automatically. Remember the user's choice across visits.
What to check once it's built
- Contrast: text that was fine on a white background may fail contrast on dark backgrounds, and vice versa — check headings, body text and muted/secondary text in both modes.
- Images and logos: a logo designed for light backgrounds can disappear or look wrong on dark — you may need a separate dark-mode logo asset.
- Custom-coloured elements: anything with a hardcoded colour (not a theme variable) won't switch automatically — ask Lovable to find and fix these.
- Third-party embeds: payment forms, maps, or chat widgets often have their own fixed styling and won't follow your dark mode — this is a real limitation, not a bug to chase.
- Persistence: confirm the chosen theme persists across page reloads and, ideally, respects the visitor's system preference by default on first visit.
What usually goes wrong
- Toggling dark mode reveals text or icons that are invisible (dark text on dark background) because they were hardcoded rather than using theme variables — this is the most common issue, and worth a dedicated pass.
- Building dark mode only for the pages you tested, missing others — ask Lovable to sweep every page.
- Adding dark mode without a visible, easy-to-find toggle — placement in the header or footer, not buried in settings, unless the site is an authenticated app with a settings page.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I make my Lovable website look less AI-generated?Set a real colour palette, a font pairing and spacing scale up front, then ask Lovable to remove generic gradients, stock-photo hero clichés and default shadcn styling so the site reads as bespoke.
- AnswerHow do I add animations?Ask for specific, subtle animations (fade-in on scroll, hover states, a smooth page transition) rather than "add animations" generally — Lovable can use Tailwind transitions or a library like Framer Motion depending on what you need.
- AnswerHow do I improve accessibility?Ask Lovable to check colour contrast, add alt text to images, ensure keyboard navigation works, and use semantic HTML/ARIA labels — these cover most common accessibility gaps in generated sites without needing a full audit tool.
- AnswerHow do I make a sticky header?Ask Lovable to make the header `fixed` or `sticky` at the top with a defined z-index, and add top padding to the page content equal to the header's height so it isn't hidden underneath.