browserAction.setBadgeBackgroundColor()

Sets the background color for the badge.

Syntax

browser.browserAction.setBadgeBackgroundColor(
  details // object
)

Parameters

details
object.
color
The color, specified as one of:
tabIdOptional
integer. Sets the badge background color only for the given tab.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 45.0 No 33

Examples

A background color that starts off as red, and turns green when the browser action is clicked:

browser.browserAction.setBadgeText({text: "1234"});
browser.browserAction.setBadgeBackgroundColor({color: "red"});

browser.browserAction.onClicked.addListener(()=> {
  browser.browserAction.setBadgeBackgroundColor({color: "green"});
});

Set the badge background color only for the active tab:

browser.browserAction.setBadgeText({text: "1234"});
browser.browserAction.setBadgeBackgroundColor({color: "red"});

browser.browserAction.onClicked.addListener((tab)=> {
  browser.browserAction.setBadgeBackgroundColor({
    color: "green",
    tabId: tab.id
  });
});

Acknowledgements

This API is based on Chromium's chrome.browserAction API. This documentation is derived from browser_action.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg, Makyen, chrisdavidmills
 Last updated by: wbamberg,