Dark Mode Best Practices in React Native
Implementing dark mode correctly in React Native requires more than swapping colors. A practical guide to doing it right.
Abhinav Birajdar
Creator
The Problem with "Just Invert the Colors"
Dark mode is not a simple color inversion. Apps that implement it that way look jarring, lose hierarchy, and often introduce accessibility issues. Done well, dark mode is a complete alternate visual language — not just black where white was.
Detecting System Appearance
Always follow the system setting as the default, with an optional user override.
jsx1import { useColorScheme } from 'react-native'; 2 3function App() { 4 const systemTheme = useColorScheme(); // 'light' | 'dark' | null 5 const [userTheme, setUserTheme] = useState(null); // overrides system 6 const theme = userTheme ?? systemTheme ?? 'light'; 7 8 return ( 9 <ThemeProvider value={theme === 'dark' ? darkTheme : lightTheme}> 10 <Navigation /> 11 </ThemeProvider> 12 ); 13}
Building a Proper Color Palette
Light and dark palettes are different designs, not inverses of each other.
Key principles:
- Dark mode backgrounds are dark grey, not pure black (
#000000) — pure black causes harsh contrast and eye strain on OLED screens. Use#121212or#1C1C1E. - Surface layers use slightly lighter greys to create elevation hierarchy without shadows.
- Saturated colors may need to be desaturated in dark mode to avoid vibrating against dark backgrounds.
- White text on dark backgrounds should be slightly off-white (e.g.,
rgba(255,255,255,0.87)), not pure white.
Example palette:
typescript1export const colors = { 2 light: { 3 background: '#FFFFFF', 4 surface: '#F8FAFC', 5 surfaceElevated: '#F1F5F9', 6 border: '#E2E8F0', 7 textPrimary: '#0F172A', 8 textSecondary: '#64748B', 9 textDisabled: '#CBD5E1', 10 primary: '#2563EB', 11 primaryContainer: '#EFF6FF', 12 }, 13 dark: { 14 background: '#121212', 15 surface: '#1E1E1E', 16 surfaceElevated: '#2A2A2A', 17 border: '#333333', 18 textPrimary: 'rgba(255,255,255,0.87)', 19 textSecondary: 'rgba(255,255,255,0.60)', 20 textDisabled: 'rgba(255,255,255,0.38)', 21 primary: '#60A5FA', // lighter blue for dark mode 22 primaryContainer: '#1E3A5F', 23 }, 24};
Elevation in Dark Mode
Material Design 3 uses tonal elevation in dark mode: surfaces at higher elevations use slightly lighter tones (overlays of white at low opacity) rather than shadows.
javascript1// Tonal elevation values for dark mode 2const darkElevation = { 3 level0: 'transparent', // 0% overlay 4 level1: 'rgba(255,255,255,0.05)', // Cards 5 level2: 'rgba(255,255,255,0.08)', // Menus, drawers 6 level3: 'rgba(255,255,255,0.11)', // FAB 7 level4: 'rgba(255,255,255,0.12)', // Bottom sheets 8 level5: 'rgba(255,255,255,0.14)', // Navigation bars 9};
Images and Media in Dark Mode
Images don't automatically adapt to dark mode. Options:
- Reduce image brightness slightly with a dark overlay (
rgba(0,0,0,0.1)) - Provide dark-mode variants for icon/illustration assets (especially for flat illustrations)
- Use adaptive icons — different assets for light vs dark context
jsx1const { dark } = useTheme(); 2 3// Adaptive image based on theme 4<Image 5 source={dark ? require('./logo-dark.png') : require('./logo-light.png')} 6 style={[styles.logo, dark && { opacity: 0.9 }]} 7/>
Testing Dark Mode
Don't rely only on visual inspection. Test systematically:
Device Testing
- Toggle system dark mode on both iOS and Android
- Test at all hours (night mode scheduler sometimes differs)
- Test on OLED and LCD screens — they behave differently
Automated Testing
jsx1// Render in both themes in your tests 2it('renders correctly in dark mode', () => { 3 const { toJSON } = render( 4 <ThemeProvider value={darkTheme}> 5 <MyComponent /> 6 </ThemeProvider> 7 ); 8 expect(toJSON()).toMatchSnapshot(); 9});
Common Dark Mode Mistakes
❌ Pure black (#000000) background
✅ Dark grey (#121212) background
❌ Pure white (#FFFFFF) text on dark background
✅ Off-white (rgba(255,255,255,0.87)) text
❌ Identical shadows in dark mode ✅ Tonal elevation overlays instead of shadows
❌ Saturated brand colors unchanged in dark mode ✅ Lighter, less saturated variants for dark backgrounds
❌ Converting a light-only app to dark mode as an afterthought ✅ Designing for both themes from day one
Conclusion
Great dark mode is invisible — users don't think about it, they just prefer your app in the evening. Invest in a proper dual palette, test on real devices, and design for both themes from the beginning. The payoff in user satisfaction is well worth the effort.