Skip to main content
Version: v4

@capacitor/splash-screen

The Splash Screen API provides methods for showing or hiding a Splash image.

Install

npm install @capacitor/splash-screen
npx cap sync

Example

import { SplashScreen } from '@capacitor/splash-screen';

// Hide the splash (you should do this on app launch)
await SplashScreen.hide();

// Show the splash for an indefinite amount of time:
await SplashScreen.show({
autoHide: false,
});

// Show the splash for two seconds and then automatically hide it:
await SplashScreen.show({
showDuration: 2000,
autoHide: true,
});

Hiding the Splash Screen

By default, the Splash Screen is set to automatically hide after 500 ms.

If you want to be sure the splash screen never disappears before your app is ready, set launchAutoHide to false; the splash screen will then stay visible until manually hidden. For the best user experience, your app should call hide() as soon as possible.

If, instead, you want to show the splash screen for a fixed amount of time, set launchShowDuration in your Capacitor configuration file.

Background Color

In certain conditions, especially if the splash screen does not fully cover the device screen, it might happen that the app screen is visible around the corners (due to transparency). Instead of showing a transparent color, you can set a backgroundColor to cover those areas.

Possible values for backgroundColor are either #RRGGBB or #RRGGBBAA.

Spinner

If you want to show a spinner on top of the splash screen, set showSpinner to true in your Capacitor configuration file.

You can customize the appearance of the spinner with the following configuration.

For Android, androidSpinnerStyle has the following options:

  • horizontal
  • small
  • large (default)
  • inverse
  • smallInverse
  • largeInverse

For iOS, iosSpinnerStyle has the following options:

  • large (default)
  • small

To set the color of the spinner use spinnerColor, values are either #RRGGBB or #RRGGBBAA.

Configuration

These config values are available:

PropTypeDescriptionDefaultSince
launchShowDurationnumberHow long to show the launch splash screen when autoHide is enabled (in ms)5001.0.0
launchAutoHidebooleanWhether to auto hide the splash after launchShowDuration.true1.0.0
backgroundColorstringColor of the background of the Splash Screen in hex format, #RRGGBB or #RRGGBBAA. Doesn't work if useDialog is true or on launch when using the Android 12 API.1.0.0
androidSplashResourceNamestringName of the resource to be used as Splash Screen. Doesn't work on launch when using the Android 12 API. Only available on Android.splash1.0.0
androidScaleType'CENTER' | 'CENTER_CROP' | 'CENTER_INSIDE' | 'FIT_CENTER' | 'FIT_END' | 'FIT_START' | 'FIT_XY' | 'MATRIX'The ImageView.ScaleType used to scale the Splash Screen image. Doesn't work if useDialog is true or on launch when using the Android 12 API. Only available on Android.FIT_XY1.0.0
showSpinnerbooleanShow a loading spinner on the Splash Screen. Doesn't work if useDialog is true or on launch when using the Android 12 API.1.0.0
androidSpinnerStyle'horizontal' | 'small' | 'large' | 'inverse' | 'smallInverse' | 'largeInverse'Style of the Android spinner. Doesn't work if useDialog is true or on launch when using the Android 12 API.large1.0.0
iosSpinnerStyle'small' | 'large'Style of the iOS spinner. Doesn't work if useDialog is true. Only available on iOS.large1.0.0
spinnerColorstringColor of the spinner in hex format, #RRGGBB or #RRGGBBAA. Doesn't work if useDialog is true or on launch when using the Android 12 API.1.0.0
splashFullScreenbooleanHide the status bar on the Splash Screen. Doesn't work on launch when using the Android 12 API. Only available on Android.1.0.0
splashImmersivebooleanHide the status bar and the software navigation buttons on the Splash Screen. Doesn't work on launch when using the Android 12 API. Only available on Android.1.0.0
layoutNamestringIf useDialog is set to true, configure the Dialog layout. If useDialog is not set or false, use a layout instead of the ImageView. Doesn't work on launch when using the Android 12 API. Only available on Android.1.1.0
useDialogbooleanUse a Dialog instead of an ImageView. If layoutName is not configured, it will use a layout that uses the splash image as background. Doesn't work on launch when using the Android 12 API. Only available on Android.1.1.0

Examples

In capacitor.config.json:

{
"plugins": {
"SplashScreen": {
"launchShowDuration": 3000,
"launchAutoHide": true,
"backgroundColor": "#ffffffff",
"androidSplashResourceName": "splash",
"androidScaleType": "CENTER_CROP",
"showSpinner": true,
"androidSpinnerStyle": "large",
"iosSpinnerStyle": "small",
"spinnerColor": "#999999",
"splashFullScreen": true,
"splashImmersive": true,
"layoutName": "launch_screen",
"useDialog": true
}
}
}

In capacitor.config.ts:

/// <reference types="@capacitor/splash-screen" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
plugins: {
SplashScreen: {
launchShowDuration: 3000,
launchAutoHide: true,
backgroundColor: "#ffffffff",
androidSplashResourceName: "splash",
androidScaleType: "CENTER_CROP",
showSpinner: true,
androidSpinnerStyle: "large",
iosSpinnerStyle: "small",
spinnerColor: "#999999",
splashFullScreen: true,
splashImmersive: true,
layoutName: "launch_screen",
useDialog: true,
},
},
};

export default config;

Android

To use splash screen images named something other than splash.png, set androidSplashResourceName to the new resource name. Additionally, in android/app/src/main/res/values/styles.xml, change the resource name in the following block:

<style name="AppTheme.NoActionBarLaunch" parent="AppTheme.NoActionBar">
<item name="android:background">@drawable/NAME</item>
</style>

Android 12 Splash Screen API

This only affects the launch splash screen and is not used when utilizing the programmatic show() method.

To enable the new recommended Android 12 Splash Screen API in SDK Versions 30 or below:

This is enabled by default and required for SDK version 31+.

  • Add $coreSplashScreenVersion to the variables.gradle file. See Variables Section for more information

  • Add implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" in the dependencies section of /android/app/build.gradle.

  • In android/app/src/main/res/values/styles.xml, edit the theme parent attribute on the Applications's MainActivity Theme to Theme.SplashScreen and add desired options to the theme.

<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
<item name="android:background">@drawable/splash</item>
</style>

NOTE: Some issues may exist on SDK >= 31 when using the new API for the splash screen, which pertain to the splash screen only showing when launched from the launcher icon. Google Issue Tracker

Variables

This plugin will use the following project variables (defined in your app's variables.gradle file):

$coreSplashScreenVersion version of androidx.core:core-splashscreen:$coreSplashScreenVersion (default: 1.0.0-rc01)

Example Guides

Adding Your Own Icons and Splash Screen Images โ€บ

Creating a Dynamic/Adaptable Splash Screen for Capacitor (Android) โ€บ

API

show(...)

show(options?: ShowOptions | undefined) => Promise<void>

Show the splash screen

ParamType
optionsShowOptions

Since: 1.0.0


hide(...)

hide(options?: HideOptions | undefined) => Promise<void>

Hide the splash screen

ParamType
optionsHideOptions

Since: 1.0.0


Interfaces

ShowOptions

PropTypeDescriptionDefaultSince
autoHidebooleanWhether to auto hide the splash after showDuration1.0.0
fadeInDurationnumberHow long (in ms) to fade in.2001.0.0
fadeOutDurationnumberHow long (in ms) to fade out.2001.0.0
showDurationnumberHow long to show the splash screen when autoHide is enabled (in ms)30001.0.0

HideOptions

PropTypeDescriptionDefaultSince
fadeOutDurationnumberHow long (in ms) to fade out.2001.0.0