browserAction.setBadgeText()

Sets the badge text for the browser action. The badge is displayed on top of the icon.

Syntax

browser.browserAction.setBadgeText(
  details // object
)

This API is also available as browser.browserAction.setBadgeText().

Parameters

details
object.
text
string. Any number of characters can be passed, but only about four can fit in the space.
tabIdOptional
integer. Set the badge text only for the given tab.

Browser compatibility

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

Examples

Add a badge indicating how many times the user clicked the button:

var clicks = 0;

function increment() {
  browser.browserAction.setBadgeText({text: (++clicks).toString()});
}

browser.browserAction.onClicked.addListener(increment);

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
 Last updated by: wbamberg,