Skip to content

Theming Overview

RNC Theme is a comprehensive theming system designed for React Native applications. It provides type-safe, dynamic theme switching with extensive customization capabilities.

Type-Safe Theming

Full TypeScript support with intelligent autocomplete for all theme properties and values.

Dynamic Theme Switching

Seamless switching between light, dark, and system themes with smooth animations.

High Customization

Extensive customization options for colors, typography, spacing, and component styles.

Persistent Storage

Automatic theme persistence across app sessions with AsyncStorage integration.

The RNC Theme system is built around several core concepts:

Every theme consists of five main categories:

colors: {
primary: string;
secondary: string;
background: string;
surface: string;
text: string;
textSecondary: string;
border: string;
error: string;
warning: string;
success: string;
info: string;
muted: string;
accent: string;
destructive: string;
}

The RNCProvider is the root component that provides theme context to your entire application:

import { RNCProvider } from 'rnc-theme';
export default function App() {
return (
<RNCProvider defaultTheme="system">
{/* Your app content */}
</RNCProvider>
);
}

Two primary hooks for accessing and using themes:

import { useTheme } from 'rnc-theme';
function MyComponent() {
const {
theme,
themeMode,
setThemeMode,
isDark,
updateCustomTheme,
resetTheme,
} = useTheme();
return (
<View style={{ backgroundColor: theme.colors.background }}>
<Text style={{ color: theme.colors.text }}>Hello World</Text>
</View>
);
}

Manage multiple theme presets with the theme registry:

import { themeRegistry } from 'rnc-theme';
// Register a custom theme
themeRegistry.registerPreset('myTheme', {
colors: {
primary: '#FF6B6B',
secondary: '#4ECDC4',
// ... other colors
},
// ... other theme properties
});
// Apply the theme
const { setActivePreset } = useTheme();
setActivePreset('myTheme');

Supports three theme modes:

  • Light Mode: Optimized for bright environments
  • Dark Mode: Optimized for low-light environments
  • System Mode: Automatically follows device settings
const { themeMode,setThemeMode, } = useTheme();
// Switch to dark mode
setThemeMode('dark');
// Follow system preference
setThemeMode('system');

All theme calculations are memoized to prevent unnecessary re-renders:

const styles = useThemedStyles(createStyles); // Memoized automatically