Skip to content

Instantly share code, notes, and snippets.

@Nattarat
Last active August 28, 2018 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nattarat/28ef67c28db6da8ff8164737228b6b4a to your computer and use it in GitHub Desktop.
Save Nattarat/28ef67c28db6da8ff8164737228b6b4a to your computer and use it in GitHub Desktop.
React Native : Media query
import {
Platform,
Dimensions
} from 'react-native'
import styled, {
css
} from 'styled-components'
const PLATFORM = Platform.OS
const DEVICE_WIDTH = Dimensions.get('window').width;
const DEVICE_HEIGHT = Dimensions.get('window').height;
const MOBILE = DEVICE_WIDTH <= 414
const TABLET = DEVICE_WIDTH >= 415 && DEVICE_WIDTH <= 1024
const IPHONE_X = PLATFORM === 'ios' && DEVICE_WIDTH === 375 && DEVICE_HEIGHT === 812
export const Container = styled.View`
padding: ${MOBILE ? '15px' : '30px'};
margin-top: ${IPHONE_X ? '60px' : '0'};
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment