Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save uguraktas/58894765aeed9122fe2b6e25f1422e66 to your computer and use it in GitHub Desktop.
Save uguraktas/58894765aeed9122fe2b6e25f1422e66 to your computer and use it in GitHub Desktop.
react-native-extended-stylesheet
/* 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