Shoutem UI toolkit enables you to build professionally looking React Native apps with ease.
It consists of three libraries:
Before starting make sure you have:
Create new React Native project:
$ react-native init HelloWorld
$ cd HelloWorld
Install and link @shoutem/ui
in your project:
$ npm install @shoutem/ui --save
$ react-native link
To check components in UI toolkit, simply copy the following to your index.ios.js
file of React Native project:
#file: index.ios.js
import React, { Component } from 'react';
import { Examples } from '@shoutem/ui';
export default class App extends Component<{}> {
render() {
return (
<Examples />
);
}
}
Finally, run the app!
$ react-native run-ios
To see other components, import them from @shoutem/ui
and render them.
You can also use standard React Native components in your layouts anywhere you want, but they will not inherit either the theme or the parent styles, so you will need to style them manually.
All components have default style defined by theme in theme.js file in the root of @shoutem/ui
package. Theme uses styling rules interpreted by @shoutem/theme package.
Each component can be customized with React Native inline styles or by using styleName
properties. Style name is similar to CSS class - it contains a set of styles that is applied to a component, defined in theme
Listed below are common style names that can be used in several UI toolkit components and their variations.
A gutter is an empty space between a component’s boundaries and the component’s content.
Set the same gutter for each side:
On
View
,Tile
andOverlay
components, gutter is applied as padding, while onText
(Typography) andButton
components gutter is applied as margin.
Set the gutter for specific side:
flexbox
to component so it fills parent container componentBelow is one example where and how common style names can be used:
<Overlay>
<Overlay styleName="collapsed"><Heading>-20%</Heading></Overlay>
<Title styleName="md-gutter-top">COOL BLACK AND WHITE STYLISH WATCHES</Title>
<Subtitle styleName="line-through sm-gutter-top">$280.00</Subtitle>
<Heading>$250.00</Heading>
<Button styleName="md-gutter-top"><Icon name="cart" /><Text>ADD TO BASKET</Text></Button>
</Overlay>
Check Shoutem Theme to learn more about styling rules, style names and how to define your own style name.