Style your components in one place.
npm install native-base-shoutem-theme@shoutem/theme is built to address that problem. With themes, you can target specific components in your app and customize them through one file, just like you would do it with CSS on the web.``bash`
$ npm install --save @shoutem/theme
All the documentation is available on the Developer portal.
Use Shoutem UI, set of components which are made to be customizable by Theme, to see how to work with it.
Create new React Native project:
`bash`
$ react-native init HelloWorld
Install @shoutem/ui and @shoutem/theme and link them in your project:
`bash`
$ cd HelloWorld
$ npm install --save @shoutem/ui
$ npm install --save @shoutem/theme
$ rnpm link
Now, simply copy the following to your index.ios.js file of React Native project:
`JavaScript
import React, { Component } from 'react';
import { AppRegistry, Dimensions } from 'react-native';
import { StyleProvider } from '@shoutem/theme';
import {
Card,
Image,
View,
Subtitle,
Caption,
} from '@shoutem/ui';
const window = Dimensions.get('window');
const Colors = {
BACKGROUND: '#ffffff',
SHADOW: '#000000',
};
const MEDIUM_GUTTER = 15;
const theme = {
'shoutem.ui.View': {
'.h-center': {
alignItems: 'center',
},
'.v-center': {
justifyContent: 'center',
},
'.flexible': {
flex: 1,
},
flexDirection: 'column',
},
'shoutem.ui.Card': {
'shoutem.ui.View.content': {
'shoutem.ui.Subtitle': {
marginBottom: MEDIUM_GUTTER,
},
flex: 1,
alignSelf: 'stretch',
padding: 10,
},
width: (180 / 375) * window.width,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'flex-start',
backgroundColor: Colors.BACKGROUND,
borderRadius: 2,
shadowColor: Colors.SHADOW,
shadowOpacity: 0.1,
shadowOffset: { width: 1, height: 1 },
},
'shoutem.ui.Image': {
'.medium-wide': {
width: (180 / 375) * window.width,
height: 85,
},
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
resizeMode: 'cover',
backgroundColor: Colors.BACKGROUND,
},
};
class HelloWorld extends Component {
render() {
return (
source={{ uri: 'http://shoutem.github.io/img/ui-toolkit/examples/image-12.png' }}
/>
Lady Gaga Sings National Anthem at Super Bowl 50
);
}
}
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
`
Finally, run the app!
`bash``
$ react-native run-ios
Shoutem UI is a part of the Shoutem UI Toolkit that enables you to build professionally looking React Native apps with ease.
It consists of three libraries:
- @shoutem/ui: beautiful and customizable UI components
- @shoutem/theme: “CSS-way" of styling entire app
- @shoutem/animation: declarative way of applying ready-made animations
The BSD License
Copyright (c) 2016-present, Shoutem