react-native-css-modules-theme
API
;
Example
import theme from 'react-native-css-modules-themes';const themes = ; const withTheme = ;const styles = ; stylestheme = 'dark'; <View = />; // Will output://// <View style={[{ fontSize: 12 }, { color: 'black' }]} />
// themes.css.light { --primary-color: white;}.dark { --primary-color: black;} // Button.css.button { font-size: 12px; background-color: var(--primary-color);}
Context Provider example
// theme.jsimport theme from 'react-native-css-modules-themes';const themes = ;themes; // Button.jsimport theme from './theme';const styles = ; <ThemeContext.Consumer> { stylestheme = theme; return <View = /> } </ThemeContext.Consumer> // App.js <ThemeContext.Provider ="dark"> <Button /> </ThemeContext.Provider>;
Mobx example
// theme.jsimport theme from 'react-native-css-modules-themes';const themes = ;themes; // Button.jsimport theme from './theme';const styles = ; @@observer { stylestheme = thispropstheme; return <View = /> ; }