xref: /expo/docs/pages/tutorial/configuration.mdx (revision dfd15ebd)
1---
2title: Configure status bar, splash screen and app icon
3---
4
5import ImageSpotlight from '~/components/plugins/ImageSpotlight';
6import Video from '~/components/plugins/Video';
7import { Collapsible } from '~/ui/components/Collapsible';
8import { LinkBase } from '~/ui/components/Text';
9import { Terminal } from '~/ui/components/Snippet';
10
11Before considering the app fully launchable, we have to configure the status bar, add a splash screen, and add an app icon. In this chapter, we will learn how to do all of that.
12
13## Step 1: Configure the status bar
14
15The <LinkBase href="/versions/latest/sdk/status-bar/" openInNewTab>`expo-status-bar`</LinkBase> library comes pre-installed in every project created using `create-expo-app`. This library provides a `<StatusBar>` component that allows configuring the app's status bar to change the text color, background color, make it translucent, and so on.
16
17The `<StatusBar>` component is already imported in the **App.js**:
18
19```jsx App.js
20import { StatusBar } from 'expo-status-bar';
21```
22
23It's also mounted in the `<App>` component.
24
25```jsx App.js
26<StatusBar style="auto" />
27```
28
29Currently, the `style` value is `auto`. It means that the status bar will automatically pick the text color based on the app's color scheme. However, we do not have different color schemes in the tutorial app. There is only one active color scheme, which has a dark background. To make the status bar light, change the `style` value to `light`.
30
31```jsx App.js
32<StatusBar style="light" />
33```
34
35<ImageSpotlight
36  alt="Break down of initial layout."
37  src="/static/images/tutorial/statusbar-example.jpg"
38  style={{ maxWidth: 480 }}
39/>
40
41## Step 2: Splash screen
42
43A splash screen is a screen that is visible before the contents of the app has had a chance to load. It hides once the app is ready for use and the content is ready to be displayed.
44
45The splash screen is configured by defining a path to the `"splash.image"` property in the <LinkBase href="/workflow/configuration/" openInNewTab>**app.json** file</LinkBase>. It has a current value of `"./assets/splash.png"` path. This is already done by default when a new Expo project is created.
46
47We already have **splash.png** in the **assets** directory. It looks as shown below:
48
49<ImageSpotlight
50  src="/static/images/tutorial/splash.png"
51  style={{ maxWidth: 250 }}
52  containerStyle={{ marginBottom: 20 }}
53/>
54
55Let's take a look at our app now on Android, and iOS:
56
57<Video file={'tutorial/splash-add.mp4'} />
58
59<Collapsible summary="Is the app loading too quickly for you to get a good look at the splash screen?">
60
61You can make the splash screen stick around for longer by manually controlling when it is hidden, rather than the default of automatically hiding it as soon as the app is ready.
62
63Start by running the following command:
64
65<Terminal cmd={['$ npx expo install expo-splash-screen']} />
66
67Next, add the following code in **App.js** to delay hiding the splash screen for five seconds.
68
69```jsx App.js
70import * as SplashScreen from 'expo-splash-screen';
71
72SplashScreen.preventAutoHideAsync();
73setTimeout(SplashScreen.hideAsync, 5000);
74```
75
76Don't forget to remove this code when you are done testing your splash screen!
77
78</Collapsible>
79
80Notice that there is a white bar on the edges of the Android device in the above demo. Depending on the resolution of the device, it might not be visible. To resolve this, we need to set the `backgroundColor` for the splash screen. The background color is applied to any screen area that isn't covered by the splash image.
81
82## Step 3: Configure the splash screen background color
83
84We can configure the splash screen's background color in **app.json** file. Open it and make the following change in `"splash"`:
85
86{/* prettier-ignore */}
87```json app.json
88{
89  "splash": {
90    "image": "./assets/splash.png",
91    "resizeMode": "contain",
92    /* @info Use #25292e (black) instead of the default #ffffff (white). */
93    "backgroundColor": "#25292e" /* @end */
94  }
95}
96```
97
98The `backgroundColor` value in the above snippet matches the background of the splash screen image.
99
100Let's take a look at our app now on Android, and iOS:
101
102<Video file={'tutorial/splash-fixed.mp4'} />
103
104## Step 4: App icon
105
106Inside the project, there's an **icon.png** file inside **assets** directory. This is our app icon. It's a 1024px by 1024px image and looks as shown below:
107
108<ImageSpotlight src="/static/images/tutorial/icon.png" style={{ maxWidth: 150 }} />
109
110Similar to splash screen image, the icon is configured by defining a path to the `"icon"` property in the **app.json** file. It has a current value of `"./assets/icon.png"`, so we don't have to change anything.
111
112> Eventually, when you build the app for the app stores, Expo Application Services (EAS) will take this image and create optimized icon for every device.
113
114You can see the icon in various places in Expo Go. Here is an example of the app icon displayed in the developer menu of Expo Go:
115
116<ImageSpotlight
117  alt="Splash screen on Developer Menu in Expo Go app."
118  src="/static/images/tutorial/app-icon-visible.jpg"
119  style={{ maxWidth: 250 }}
120  containerStyle={{ marginBottom: 0 }}
121/>
122
123## We have completed the app!
124
125Well done! We built an app that runs on Android, iOS, and the web from the same codebase.
126
127The next section of the tutorial will guide us towards resources to learn more about concepts we've covered here and others we have only mentioned in passing. [Continue to find out how you can learn more](/tutorial/follow-up).
128