Overview
TheuseColorScheme hook is a re-export of React Native’s built-in hook that detects the device’s current color scheme preference.
Import
Return Value
The current color scheme. Returns
'light', 'dark', or null if the color scheme cannot be determined.Implementation
This hook simply re-exports React Native’suseColorScheme:
useColorScheme.web.ts:
Usage Example
Platform Differences
- Mobile (iOS/Android): Returns the device’s system color scheme
- Web: Always returns
'light'(as defined inuseColorScheme.web.ts)
Used By
This hook is used internally by:- useThemeColor - To determine which color to use based on the current theme
- ThemedText - To apply theme-aware text colors
- ThemedView - To apply theme-aware background colors
Related
- useThemeColor - Get colors based on the current theme
- React Native useColorScheme - Official documentation
