vitalets / react-native-extended-stylesheet

Extended StyleSheets for React Native
MIT License
2.93k stars 132 forks source link

Global styles #42

Closed lucasff closed 7 years ago

lucasff commented 7 years ago

It is possible to have global styles, like we have in CSS?

vitalets commented 7 years ago

Yes, you can create global style file

// global.js
export EStyleSheet.create({
...
});

and use it in all other components:

// component
import style from `./global`;
...

AFAIK React Native can not automatically apply some style to components.

NguyenPhatBG commented 6 years ago

I know a new way to create Global style, and if we're combined react-native-extended-stylesheet, It's so crazy :) Need create a new file Global.js, create a global variable like this.

export styles = EStyleSheet.create({
 container :{
  flex: 1,
  justifyContent:'center',
  alignItems:'center'
}
}) ,
....
global.GlobalStyle = styles;

Now simpler to import ./Global.js to App.js (file root) All app you can use: GlobalStyle.container