Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Change the Status Bar Color on iOS and Android in a PWA

    reactReact
    16.6.3-16.8.6
    javascriptJavaScript
    androidAndroid
    iosiOS

    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.

    Code

    Code

    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 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.

    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.

    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.

    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.

    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.

    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.