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 chrome.browserAction.setBadgeText().

Parameters

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

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesYes45NoYes

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: SphinxKnight, freaktechnik, groovecoder, wbamberg, Makyen
 Last updated by: SphinxKnight,