Would like to be able to set portrait and landscape views on the styles object for tablets in Material UI
const styles = theme => ({
root: {
padding: theme.spacing.unit,
[theme.breakpoints.up('md')]: {
backgroundColor: theme.palette.secondary.main
}
}
}
how can i add breakpoints for portrait view and landscape view similar to the traditional media query:
@media screen and (orientation: landscape) {
body {
flex-direction: row;
}
}
@media screen and (orientation: portrait) {
body {
flex-direction: column;
}
}
Would like to be able to set portrait and landscape views on the styles object for tablets in Material UI
const styles = theme => ({
root: {
padding: theme.spacing.unit,
[theme.breakpoints.up('md')]: {
backgroundColor: theme.palette.secondary.main
}
}
}
how can i add breakpoints for portrait view and landscape view similar to the traditional media query:
@media screen and (orientation: landscape) {
body {
flex-direction: row;
}
}
@media screen and (orientation: portrait) {
body {
flex-direction: column;
}
}
Share
Improve this question
edited Sep 6, 2018 at 17:54
Julio Cornelio
asked Sep 3, 2018 at 13:08
Julio CornelioJulio Cornelio
1711 gold badge2 silver badges6 bronze badges
1
- 1 what issue you're facing ? – Sakhi Mansoor Commented Sep 3, 2018 at 13:09
3 Answers
Reset to default 10Just set something like that:
const styles = theme => ({
root: {
padding: theme.spacing.unit,
[`${theme.breakpoints.up('md')} and (orientation: portrait)`]: {
flexDirection: 'column'
}
}
}
You're able to use something like this:
'@media (orientation: landscape)': {
flexDirection: `orientation`,
},
for the component media query will be attached.
Used this in version 4.11.1
const useStyles = makeStyle((theme) =>({
container:{
border:"1px dashed red",
[theme.breakpoints.down("md")]{
border: "1px solid blue",
'@media (orientation: landscape)': {
border: "1px solid green",,
},
},
},
}));