The default status bar color on iOS doesn't look great with the color scheme of our application, so we'll set a custom theme color for Android, and a status bar meta tag for iOS. We can't set a fully custom status bar color in iOS, but we can set the apple-mobile-web-app-status-bar-style
meta tag to either default
, black
, or black-translucent
.
Instructor: [00:00] The status bar of a PWA installed as a standalone app may not look the way you want it to. First let's open manifest.json. There we're going to make sure that the background color is white. Let's set a theme color to the React Logo blue color, so we can see what that does as well.
[00:22] In index.html, we can find and change the theme color there, too. On iOS we only have a limited status bar customization, so we have to add a meta tag called apple-mobile-web-app-status-bar-style, which can only take three values -- default, black, or black translucent.
[00:50] For this example, I know that default looks the best, but you'll have to experiment for your application, because there are some interesting intersections between the theme color, background color, and the app status bar style. Now we can build and serve that. I'm actually going to launch a second server here on another port.
[01:09] I've been testing this on the iPhone already, and the iOS browser really aggressively caches the values for the status bar. By just changing the port number, it appears to iOS like a brand new application. If your status bar or any other value from your manifest on iOS isn't updating correctly, you may try a new port to see if that fixes the issue for development.
[01:31] Now starting an Android, we can view the app and see the status bar area turn the React blue color, which matches the theme color. On iOS, we can navigate to the app in Safari and install it on the home screen.
[01:49] When we boot the app in standalone mode, we see that the status bar has turned white with black text, which is the behavior for the default setting with this background and theme color combination. Notice that on iOS the theme color isn't displayed anywhere in the header though, because iOS doesn't let us set the status bar to fully custom colors.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!