Skip to main content

changeTheme

Description

Switches the app's current color theme. Pass a theme index to switch to that theme right away. Pass 2 to switch to automatic mode, which follows the device OS light/dark setting instead of a specific index.

Parameters

NameTypeDescription
typeintTheme index to apply
(Example)
0, 1 — Light, Dark, and any other theme configured in the Theme settings).
2 is a reserved value that switches to automatic mode, following the device OS setting instead of a specific index.

Returns

void

Example

$app.changeTheme(1); // Switch to theme index 1
$app.changeTheme(2); // Follow the device OS light/dark setting
  • $app.isDarkTheme() — Whether the app's current theme is dark
  • $app.isDeviceDarkTheme() — Whether the device OS is set to dark mode
  • $app.colorValue(themeName, optionValue) — Look up a color value from a theme