Overview
The theme system provides:- Automatic light/dark mode switching
- Consistent color palette across the app
- Platform-specific font configurations
- Type-safe theme access
- Custom color overrides
Color Scheme
Colors are defined insrc/constants/theme.ts with separate palettes for light and dark modes.
Color Definitions
src/constants/theme.ts
Available Color Keys
text
text
Primary text color
- Light:
#11181C(dark gray) - Dark:
#ECEDEE(light gray)
background
background
Background color for views and containers
- Light:
#fff(white) - Dark:
#151718(near black)
tint
tint
Primary accent color for interactive elements
- Light:
#0a7ea4(blue) - Dark:
#fff(white)
icon
icon
Default icon color
- Light:
#687076(medium gray) - Dark:
#9BA1A6(light gray)
tabIconDefault
tabIconDefault
Unselected tab icon color
- Light:
#687076 - Dark:
#9BA1A6
tabIconSelected
tabIconSelected
Selected tab icon color
- Light:
#0a7ea4 - Dark:
#fff
Customizing Colors
Adding New Color Keys
To add new colors to the theme:Overriding Default Colors
You can override theme colors per-component:Font System
The font system provides platform-specific font families:src/constants/theme.ts
Using Fonts
- With StyleSheet
- Inline Styles
Theme Hooks
useColorScheme
Detects the current color scheme:src/hooks/use-color-scheme.ts
On web, this hook uses
window.matchMedia('(prefers-color-scheme: dark)') to detect the color scheme. On native, it uses React Native’s built-in useColorScheme hook.useThemeColor
Resolves colors based on the current theme:src/hooks/use-theme-color.ts
Themed Components
ThemedText
Automatically themed text with predefined styles:ThemedView
Automatically themed view container:Theme Provider Setup
The theme is configured in the root layout:src/app/_layout.tsx
- Navigation elements match the current theme
- Theme changes propagate throughout the app
- System preference changes are detected
Best Practices
Use Semantic Names
Name colors by purpose (e.g.,
primary, danger) rather than appearance (e.g., blue, red)Test Both Themes
Always test your UI in both light and dark modes to ensure readability
Consistent Contrast
Maintain WCAG AA contrast ratios (4.5:1 for normal text)
Use Themed Components
Prefer
ThemedText and ThemedView over raw React Native componentsAlternative Styling Solutions
While NearYou uses a custom theme system, you can also use these popular alternatives:
- NativeWind - Tailwind CSS for React Native
- Tamagui - Universal UI kit with themes
- Unistyles - Zero-runtime styling
Next Steps
Components
Explore themed components
Navigation
Configure app navigation