Using Bottom Tab Bars on Safari iOS 15
Tags: tabbar, safari, ios, css
Published: 2021-06-23 08:51:39

**Apple recently announced the latest version of Safari on iOS 15 with a completely new design featuring a bottom floating tab bar. What does this mean for web developers and designers?**

Safari on iOS has had a problem for a long time when it comes to building websites and web apps with bottom-aligned navigation due to the browser toolbar's dynamic height. As you scroll the toolbar disappears making any element that is fixed to the bottom of the screen look great, but as soon as you try to tap any link inside the browser toolbar appears again. 

{% youtube 5QVFKL11nh8 %}

This makes for a really poor UX so designers and developers have mostly resorted to user "hamburger" menus instead. This is a shame as bottom tab bars increase discoverability by not hiding links behind a tap and are also easier to reach one-handed on todays large mobile devices.

## Updates with Safari 15

The new Safari 15 now has a tab bar floating at the bottom of the screen. At first it might seem like this makes it even harder to create tab bar navigations, and by browsing the web using iOS 15 it's easy to spot issues like this:

{% youtube BcS7zV3RzM0 %}

## Fixing Tab Bar Overlap with Safe Areas

Thankfully solving this issue is very easy by using the `env()` CSS function together with `safe-area-inset-bottom`. This API was shipped with iOS 11 making it possible to customize how websites render when using devices with a notch. By inspecting pinterests code we can see that their tab bar has a fixed position anchored to the bottom, the relevant parts look something like this:

```css
.tabbar {
	position: fixed;
	bottom: 0;
}
```

To respect the safe area and make sure that nothing from the browser UI overlaps let's add another bottom property with `env(safe-area-inset-bottom)` as a value. This function works like a CSS variable, returning the minimum amount of inset needed to keep your UI from overlapping with the browser's. We keep the old style rule as a fallback browsers that do not support it:

```css
.tabbar {
  position: fixed;
  bottom: 0;
  bottom: env(safe-area-inset-bottom);
}
```

Now when scrolling nothing overlaps:

{% youtube KKhn7JHtma0 %}

Be sure to use `env()` every time something is anchored to the bottom of the screen or overlap will likely appear. `env()` can also be combined with css `calc()` or `min()` and `max()`. You can learn more about this and respecting safe-area in [this excellent article](https://webkit.org/blog/7929/designing-websites-for-iphone-x/) published on the webkit blog.

The easiest way to test your websites is to download the Xcode 13 beta from [Apples developer portal](https://developer.apple.com/download/) and using an iOS 15 simulator by going to `Xcode > Open Developer Tool > Simulator`

## Tab Bar UX in iOS 15

Remember the issue in previous versions of Safari where you had to click twice when using bottom tab bars? Once for showing the safari toolbar and another tap for actually triggering your link? That is no longer an issue 🙌. Safari 15 now respects and follows links or buttons, which is a big improvement! Check out how much better Twitter's tabbar works when switching tabs on Safari 15:

{% youtube PvkuL0n4Gqg %}

Even if tab bars now technically work better than before we still have to consider the design and UX to create something that people understand and that looks good. The browser UI is now very bottom-heavy and placing more actions next to it might feel cluttered. What do you think? Let me know on twitter [@samuelkraft](https://twitter.com/samuelkraft).

I'm excited to see how everyone adapts to the new UI and if we will see a return of tab bars on the web or not.