An open API service indexing awesome lists of open source software.

https://github.com/suryakarmakar/reactnative-stylesheet

use inline, local/Internal, global/external style and pass multiple styles object
https://github.com/suryakarmakar/reactnative-stylesheet

Last synced: 7 months ago
JSON representation

use inline, local/Internal, global/external style and pass multiple styles object

Awesome Lists containing this project

README

          

# React Native StyleSheet

## Inline Style :

Using Inline style, you just put any style property into double curly braces {{}} before style attribute

```js
This is Inline Style
```

## Local Style :

In Local style first import StyleSheet from 'react-native'

```js
import {StyleSheet} from 'react-native'
```

Then create a styles object with StyleSheet create method

```js
const styles = StyleSheet.create({
textStyle:{
color:'green',
fontSize:20
}
})
```

Now using styles object just pass the object value with dot '.' in to style attribute

```js
This is Local/Internal Style
```

## Global Style :

In Global style first create a Styles.js file and put your all styles into this file and also export as a default

```js
export default StyleSheet.create({
textStyle:{
color:'tomato',
fontSize:20
}
})
```

Or you can make diffrent diffrent style object and export.

```js
export const globalStyle = StyleSheet.create({
textStyle:{
color:'lightblue',
fontSize:20
}
})
```

Now using Global style into your component you can just import the Styles.js file and pass the object value

```js
import Styles from './Styles';
This is Global/External Style

import {globalStyle} from './Styles';
Another way to use GlobalStyles
```

## Multiple Style Object :

You can pass multiple styles object into style attribute, using array

```js
Use Multuple Style Object
```

## Usage
```
$ git clone https://github.com/SuryaKarmakar/React-Native-StyleSheet.git
$ cd React-Native-StyleSheet
$ npm install
$ npm run [web, android, ios]
```
## Run with Expo
```
$ expo start --[web, android, ios]
```