Skip to main content
Version: 3.x

Taro.setBackgroundColor(option)

Dynamically sets the background color of the window.

Reference

Type

(option: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
backgroundColorstringNoThe background color of the window, which must be a hexadecimal value
backgroundColorBottomstringNoThe background color of the bottom window (only for iOS), which must be a hexadecimal value
backgroundColorTopstringNoThe background color of the top window (only for iOS), which must be a hexadecimal value
complete(res: CallbackResult) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
success(res: CallbackResult) => voidNoThe callback function for a successful API call

Sample Code

Taro.setBackgroundColor({
backgroundColor: '#ffffff', // The background color of the window is white.
})
Taro.setBackgroundColor({
backgroundColorTop: '#ffffff', // The background color of the top window is white.
backgroundColorBottom: '#ffffff', // The background color of the bottom window is white.
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.setBackgroundColor✔️✔️(Only Android)