Skip to content

Theme Registry

The Theme Registry is a powerful system for managing multiple theme presets in your application. It allows you to register, organize, and switch between different themes dynamically.

The registry acts as a centralized store for all your theme presets, providing:

Theme Management

Register and organize multiple theme presets with unique identifiers.

Dynamic Switching

Switch between registered themes at runtime with smooth transitions.

Persistence

Automatically persist active theme selection across app sessions.

Built-in Presets

Access pre-designed themes like Material, Neon, Ocean, and more.

Theme Discovery

List, search, and preview available themes in your registry.

import { themeRegistry } from 'rnc-theme';
import { themeRegistry } from 'rnc-theme';
// Register a static theme object
themeRegistry.registerPreset('corporate', {
colors: {
primary: '#1E40AF',
secondary: '#374151',
background: '#F9FAFB',
surface: '#FFFFFF',
text: '#111827',
textSecondary: '#6B7280',
border: '#D1D5DB',
error: '#DC2626',
warning: '#D97706',
success: '#059669',
info: '#2563EB',
muted: '#9CA3AF',
accent: '#059669',
destructive: '#B91C1C',
},
// ...rest
});

RNC Theme comes with several pre-registered theme presets:

Material

material

Google Material Design inspired theme with clean, modern aesthetics.

Neon

neon

High-contrast cyberpunk theme with electric colors.

Ocean

ocean

Calming blue and teal tones inspired by ocean depths.

Sunset

sunset

Warm oranges and pinks reminiscent of sunset skies.

Forest

forest

Natural earth tones and greens inspired by nature.

Galaxy

galaxy

Deep space colors with cosmic purple and blue hues.

Vintage

vintage

Muted, classic colors with retro aesthetic.

Cyberpunk

cyberpunk

Futuristic high-tech theme with neon accents.

Pastel

pastel

Soft, gentle colors perfect for calm interfaces.

Monochrome

monochrome

Black and white minimalist design.

Autumn

autumn

Warm fall colors with orange and brown tones.

Arctic

arctic

Cool blues and whites inspired by arctic landscapes.

import { useTheme } from 'rnc-theme';
function ThemeSelector() {
const { updateCustomTheme, Button, ButtonText } = useTheme();
const handlePreset = () =>
updateCustomTheme(
isDark ? presetThemes[2].config(true) : presetThemes[2].config(false),
presetThemes[2].key,
presetThemes[2].config
);
return (
<View>
<Button onPress={handlePreset}>
<ButtonText>
Preset Theme
</ButtonText>
</Button>
</View>
);
}
import { themeRegistry } from 'rnc-theme';
const App = () => {
// List all registered presets
console.log(themeRegistry.getAllPresets());
// Check if a preset is registered
console.log(themeRegistry.hasPreset('neon'));
// Get preset theme config
console.log(themeRegistry.getPreset('neon'));
}
// Remove a single theme
themeRegistry.deletePreset('oldTheme');
// Clear everything
themeRegistry.clearPresets();

Problem: setActivePreset('mytheme') doesn’t work

Solutions:

// Check if theme is registered
if (!themeRegistry.hasPreset('mytheme')) {
console.error('Theme not found:', 'mytheme');
console.log('Available themes:', themeRegistry.list());
}
// Register the theme first
useEffect(()=>{
themeRegistry.registerPreset('mytheme', myThemeConfig);
},[])