xref: /expo/docs/pages/tutorial/configuration.mdx (revision 2b2df482)
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 { A } from '~/ui/components/Text';
9import { Terminal } from '~/ui/components/Snippet';
10import { Step } from '~/ui/components/Step';
11
12Before 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.
13
14<Step label="1">
15
16## Configure the status bar
17
18The <A href="/versions/latest/sdk/status-bar/" openInNewTab>`expo-status-bar`</A> library comes pre-installed in every project created using `create-expo-app`.
19This 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.
20
21The `<StatusBar>` component is already imported in the **App.js**:
22
23```jsx App.js
24import { StatusBar } from 'expo-status-bar';
25```
26
27It's also mounted in the `<App>` component.
28
29```jsx App.js
30<StatusBar style="auto" />
31```
32
33Currently, the `style` value is `auto`. It means that the status bar will automatically pick the text color based on the app's color scheme.
34However, we do not have different color schemes in the tutorial app. There is only one active color scheme, which has a dark background.
35To make the status bar light, change the `style` value to `light`.
36
37```jsx App.js
38<StatusBar style="light" />
39```
40
41<ImageSpotlight
42  alt="Break down of initial layout."
43  src="/static/images/tutorial/statusbar-example.jpg"
44  style={{ maxWidth: 480 }}
45/>
46
47</Step>
48
49<Step label="2">
50
51## Splash screen
52
53A 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.
54
55The splash screen is configured by defining a path to the `"splash.image"` property in the <A href="/workflow/configuration/" openInNewTab>**app.json** file</A>.
56It has a current value of `"./assets/splash.png"` path. This is already done by default when a new Expo project is created.
57
58We already have **splash.png** in the **assets** directory. It looks as shown below:
59
60<ImageSpotlight
61  src="/static/images/tutorial/splash.png"
62  style={{ maxWidth: 250 }}
63  containerStyle={{ marginBottom: 20 }}
64/>
65
66Let's take a look at our app now on Android, and iOS:
67
68<Video file={'tutorial/splash-add.mp4'} />
69
70<Collapsible summary="Is the app loading too quickly for you to get a good look at the splash screen?">
71
72You 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.
73
74Start by running the following command:
75
76<Terminal cmd={['$ npx expo install expo-splash-screen']} />
77
78Next, add the following code in **App.js** to delay hiding the splash screen for five seconds.
79
80```jsx App.js
81import * as SplashScreen from 'expo-splash-screen';
82
83SplashScreen.preventAutoHideAsync();
84setTimeout(SplashScreen.hideAsync, 5000);
85```
86
87Don't forget to remove this code when you are done testing your splash screen!
88
89</Collapsible>
90
91Notice 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.
92
93</Step>
94
95<Step label="3">
96
97## Configure the splash screen background color
98
99We can configure the splash screen's background color in **app.json** file. Open it and make the following change in `"splash"`:
100
101{/* prettier-ignore */}
102```json app.json
103{
104  "splash": {
105    "image": "./assets/splash.png",
106    "resizeMode": "contain",
107    /* @info Use #25292e (black) instead of the default #ffffff (white). */
108    "backgroundColor": "#25292e" /* @end */
109  }
110}
111```
112
113The `backgroundColor` value in the above snippet matches the background of the splash screen image.
114
115Let's take a look at our app now on Android and iOS:
116
117<Video file={'tutorial/splash-fixed.mp4'} />
118
119</Step>
120
121<Step label="4">
122
123## App icon
124
125Inside 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:
126
127<ImageSpotlight src="/static/images/tutorial/icon.png" style={{ maxWidth: 150 }} />
128
129Similar 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.
130
131> 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.
132
133You 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:
134
135<ImageSpotlight
136  alt="Splash screen on Developer Menu in Expo Go app."
137  src="/static/images/tutorial/app-icon-visible.jpg"
138  style={{ maxWidth: 250 }}
139  containerStyle={{ marginBottom: 0 }}
140/>
141
142</Step>
143
144## We have completed the app!
145
146Well done! We built an app that runs on Android, iOS, and the web from the same codebase.
147
148The next section of the tutorial will guide you toward resources to learn more about concepts we've covered here and others we have mentioned briefly. [Continue to find out how you can learn more](/tutorial/follow-up).
149