title: Taro.setBackgroundColor(option)

sidebar_label: setBackgroundColor

Dynamically sets the background color of the window.

Reference

Type

  1. (option: Option) => Promise<CallbackResult>

Parameters

Option

Property Type Required Description
backgroundColor string No The background color of the window, which must be a hexadecimal value
backgroundColorBottom string No The background color of the bottom window (only for iOS), which must be a hexadecimal value
backgroundColorTop string No The background color of the top window (only for iOS), which must be a hexadecimal value
complete (res: CallbackResult) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: CallbackResult) => void No The callback function for a failed API call
success (res: CallbackResult) => void No The callback function for a successful API call

Sample Code

  1. Taro.setBackgroundColor({
  2. backgroundColor: '#ffffff', // The background color of the window is white.
  3. })
  4. Taro.setBackgroundColor({
  5. backgroundColorTop: '#ffffff', // The background color of the top window is white.
  6. backgroundColorBottom: '#ffffff', // The background color of the bottom window is white.
  7. })

API Support

API WeChat Mini-Program H5 React Native
Taro.setBackgroundColor ✔️ ✔️(Only Android)