# PWA safe area using env(safe-area-inset-bottom)

**URL:** <https://community.weweb.io/t/pwa-safe-area-using-env-safe-area-inset-bottom/17206>\
**Category:** Ask us anything\
**Created:** [March 16, 2025, 5:05pm UTC](https://community.weweb.io/t/pwa-safe-area-using-env-safe-area-inset-bottom/17206 "2025-03-16T17:05:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MathiasVG](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@MathiasVG](https://community.weweb.io/u/MathiasVG)\
**Post date:** [March 16, 2025, 5:05pm UTC](https://community.weweb.io/t/pwa-safe-area-using-env-safe-area-inset-bottom/17206/1 "2025-03-16T17:05:30Z")

</div>

I’m trying to make the bottom margin of a bottom bar dynamic to ensure that it respects the safe area of the device. As such, I’am using the ccs env(safe-area-inset-bottom) as bottom margin on the first container of my bottom nav.  
But when I test it (on an iPhone), it does not seems to work.

 ![Capture d’écran 2025-03-16 à 17.58.24](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0f57378e4d6c462c3b0af1cd746b7471999c4db1.png)

Is env(safe-area-inset-bottom) usable with weweb ?

---

<div class="post-metadata">

**Author:** ![andreas.schaefer](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@andreas.schaefer](https://community.weweb.io/u/andreas.schaefer)\
**Post date:** [April 3, 2025, 7:25pm UTC](https://community.weweb.io/t/pwa-safe-area-using-env-safe-area-inset-bottom/17206/2 "2025-04-03T19:25:24Z")

</div>

yeah same issue here. i’ve tried via custom css and custom code as well

---

<div class="post-metadata">

**Author:** ![jptrinh](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/jptrinh/32/1493_2.png) [@jptrinh](https://community.weweb.io/u/jptrinh)\
**Post date:** [January 19, 2026, 8:02am UTC](https://community.weweb.io/t/pwa-safe-area-using-env-safe-area-inset-bottom/17206/3 "2026-01-19T08:02:47Z")

</div>

Hello 👋  
I’ve managed to use `env(safe-area-inset-bottom)` on PWA.

The issue was that the viewport meta tag is missing `viewport-fit=cover` attribute in order to use the variable. So I’ve added this script that is initialized on page load that adds it to the header.

```auto
// Workflow on page load
const document = wwLib.getFrontDocument();

function addViewportFit() {
  let viewportMeta = document.querySelector('meta[name="viewport"]');

  if (viewportMeta) {
    if (!viewportMeta.content.includes("viewport-fit")) {
      viewportMeta.content += ", viewport-fit=cover";
    }
  } else {
    viewportMeta = document.createElement("meta");
    viewportMeta.name = "viewport";
    viewportMeta.content =
      "width=device-width, initial-scale=1.0, viewport-fit=cover";
    document.head.appendChild(viewportMeta);
  }
}

if (document.head) {
  addViewportFit();
} else {
  document.addEventListener("DOMContentLoaded", addViewportFit);
}

```

And then, on the CSS props where i need to use the env(..), I bind it as a string. And that did the trick 🙂

 ![CleanShot 2026-01-19 at 15.02.13@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/94f93d53c952b8718301a22bd596f7dfbf0a6ee2.png)
