My web app uses React with Material-UI. It has a bottom nav bar. On some devices, e.g. a current iPad, I need to leave around 8 extra pixels under it for the horizontal gray bar that the iPad has in place of a home button:
I found out via a post on StackExchange, that I need to use the CSS env() variable.
I'm trying to find the correct syntax for this. So far I've tried:
import {css} from '@emotion/react'
[.....]
<BottomNavigation
onChange={handleChange}
showLabels
css={css`
position: fixed,
left: 0px,
bottom: 0px,
height: ${50 + env(safe-area-inset-bottom)}px,
width: 100%,
zIndex: 100
`}
>
...and I got this error in the console:
Uncaught ReferenceError: env is not defined
I also tried it like this:
import {css} from '@emotion/react'
[.....]
<BottomNavigation
onChange={handleChange}
showLabels
css={css`
position: fixed,
left: 0px,
bottom: 0px,
height: 50 + env(safe-area-inset-bottom)px,
width: 100%,
zIndex: 100
`}
>
There's no error generated by this, but height evaluates to just 50, even on a new iPad.
There are a few other posts asking about this on SO, but they seem to be several years old, and the solutions proposed don't seem to apply and/or work in this case.
What's the correct way to access the CSS env() variable for use with with React and/or Material-UI?
