Created
May 26, 2019 19:51
-
-
Save uguraktas/58894765aeed9122fe2b6e25f1422e66 to your computer and use it in GitHub Desktop.
react-native-extended-stylesheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* component.js */ | |
import EStyleSheet from 'react-native-extended-stylesheet'; | |
// define extended styles | |
const styles = EStyleSheet.create({ | |
column: { | |
width: '80%' // 80% of screen width | |
}, | |
text: { | |
color: '$textColor', // global variable $textColor | |
fontSize: '1.5rem' // relative REM unit | |
}, | |
'@media (min-width: 350) and (max-width: 500)': { // media queries | |
text: { | |
fontSize: '2rem', | |
} | |
} | |
}); | |
// use styles as usual | |
class MyComponent extends React.Component { | |
render() { | |
return ( | |
<View style={styles.column}> | |
<Text style={styles.text}>Hello</Text> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment