useColorScheme hook provides access to the user’s system-level color scheme preference. It returns either "light", "dark", or null if the preference cannot be determined.
This hook is a platform-aware wrapper around React Native’s
useColorScheme. On web, it includes special handling for static rendering and hydration.Usage
Return Value
The current color scheme preference:
"light"- Light mode is active"dark"- Dark mode is activenull- Color scheme cannot be determined (rare)
"light" during SSR/static rendering and updates to the actual system preference after client-side hydration.Platform Behavior
- iOS & Android
- Web
On native platforms, this hook directly returns the value from React Native’s The value updates automatically when the user changes their system appearance settings.
useColorScheme hook, which reflects the system-level appearance setting.Examples
Basic Color Scheme Detection
Using with Theme Selection
Conditional Asset Loading
Handling Null Color Scheme
When to Use
Direct Scheme Access
Use when you need the raw color scheme value to make decisions about which theme to apply or which assets to load.
Custom Theme Logic
Use when building custom theme systems that need to respect the system color scheme but may include additional user preferences.
Analytics & Tracking
Use to track which color scheme users prefer or to segment analytics data by theme preference.
Platform-Specific Behavior
Use when you need platform-specific theme handling, especially for web apps that require hydration-safe color scheme detection.
Best Practices
Always Provide a Fallback
Always Provide a Fallback
Since
useColorScheme can return null, always provide a fallback value:Use useTheme for Styling
Use useTheme for Styling
For most styling use cases, prefer the
useTheme hook which provides ready-to-use color tokens:Consider Web Hydration
Consider Web Hydration
On web platforms, be aware that the value changes after hydration. Avoid flashing content by:
- Using CSS to hide critical themed content until hydration
- Accepting the brief transition from light to dark mode
- Using the
"light"default as your primary design
Related Hooks
useTheme
Get theme colors and dark mode state (recommended for most use cases)
useScreenOptions
Apply theme-aware navigation options to screens