Overview
TheColors constant provides a comprehensive set of theme-aware colors for both light and dark modes. These colors are used throughout the app to ensure consistent theming and automatic adaptation to the user’s color scheme preference.
Import
Color Values
Light Mode
Primary text color for light mode
Background color for light mode
Tint/accent color for light mode (brand color)
Default icon color for light mode
Inactive tab bar icon color for light mode
Active tab bar icon color for light mode
Dark Mode
Primary text color for dark mode
Background color for dark mode
Tint/accent color for dark mode
Default icon color for dark mode
Inactive tab bar icon color for dark mode
Active tab bar icon color for dark mode
Usage Examples
Direct Access
Access colors directly based on the current color scheme:With useThemeColor Hook
The recommended way to use colors is with theuseThemeColor hook:
In Styled Components
Use colors in ThemedText and ThemedView components:Type Definition
Best Practices
Use Theme-Aware Hooks
Always use
useThemeColor hook instead of accessing Colors directly. This allows for runtime color overrides and proper theme switching.Consistent Color Keys
Use the defined color keys (
text, background, tint, etc.) consistently across your app for a unified design system.Override When Needed
Pass
lightColor and darkColor props to themed components when you need to override the default colors for specific use cases.Alternative Styling Solutions
The colors constant is just one approach to theming. You can also use:- Nativewind - Tailwind CSS for React Native
- Tamagui - Universal UI kit
- unistyles - Cross-platform styling library
Related
- Fonts - Platform-specific font families
- useThemeColor - Hook for accessing theme colors
- useColorScheme - Hook for detecting color scheme