Skip to content
AnswerWell geo Documentation

Research · 6 min read · Answerwell

Extension Toolbar Action: Popup, Icon, Badge and Conditional Activation

How to register the action key, toolbar popups, icons, badges, tooltips, and declarativeContent rules in Manifest V3 extensions.

This page summarises Chrome Extensions documentation on the toolbar action: the icon users click in the browser toolbar, optional popup, badge, and tooltip, and how to enable the action only on matching pages—primarily through the Manifest V3 action API and declarativeContent.

action and toolbar icon: what happens when users click

Section titled “action and toolbar icon: what happens when users click”

An action is what runs when someone clicks your extension’s toolbar icon (the action icon). It either opens a popup HTML surface or runs code through action.onClicked—not both at once for the same click path.

An action is what happens when a user clicks the toolbar icon, usually called the action icon for your extension. An action invokes an extension feature using the Action API or opens a popup.

— Chrome, Implement an action

Use the chrome.action API to control the extension’s icon in the Google Chrome toolbar.

— Chrome, browser.action

Action icons sit next to the omnibox; after install they appear in the extensions menu until the user pins the icon. Chrome recommends including at least action and default_icon in the manifest even though every extension gets a toolbar entry.

Use a popup when users need a small control panel (multiple buttons, settings, status). Use action.onClicked when a single click should run logic with no visible HTML UI—typical with the activeTab permission.

Register the click handler at the top level of the service worker so it is not missed after worker restarts—see Migrate to a service worker.

default_popup: register and implement a toolbar popup

Section titled “default_popup: register and implement a toolbar popup”

A popup is a compact HTML page shown when the user clicks the action icon (or via a shortcut, or browser.action.openPopup() where supported).

A popup is an action that displays a window letting users invoke multiple extension features. It’s triggered by a keyboard shortcut, by clicking the extension’s action icon or by calling browser.action.openPopup(). Popups automatically close when the user focuses on some portion of the browser outside of the popup. There is no way to keep the popup open after the user has clicked away.

— Chrome, Add a popup

Set default_popup under the action key to a path relative to the extension root:

{
"manifest_version": 3,
"action": {
"default_title": "Click to view a popup",
"default_popup": "popup.html"
}
}

(See Show a popup in the Action API reference.)

Implement the popup like a normal web page; inline scripts in the HTML are not allowed—put JavaScript in a separate file linked from the popup HTML, as in Design the user interface — Popup and Add a popup.

The popup’s size must be between 25x25 and 800x600 pixels.

— Chrome, browser.action — Popup

Switch popups at runtime with action.setPopup()—for example one HTML file when signed in and another when not (Add a popup).

(The docs also note openPopup() in User interface components — Popups; behaviour depends on context and permissions—test in your target Chrome version.)

default_icon and manifest icons: sizes and formats

Section titled “default_icon and manifest icons: sizes and formats”

Toolbar display uses action.default_icon. Broader branding uses the top-level icons key (Configure extension icons, Manifest — Icons).

Size Typical use
16×16 Toolbar (16 DIPs), favicon on extension pages, context menu
32×32 Often used on Windows
48×48 chrome://extensions management page
128×128 Install UI and Chrome Web Store listing

Icons must be 16 device-independent pixels (DIPs) wide and tall.

— Chrome, browser.action — Icon

Provide several sizes in default_icon so Chrome can pick the best match; otherwise it scales the nearest asset, which may look soft (browser.action — Icon). Unpacked extensions should use PNG for action icons; packed extensions support more raster formats; SVG is not supported for manifest icons (Configure extension icons).

Change the icon programmatically with action.setIcon() (static images only—do not use animated icons).

default_title, setBadgeText and per-tab action state

Section titled “default_title, setBadgeText and per-tab action state”

Tooltip: set default_title on action, or call action.setTitle(). If unset, the extension name is shown (Implement an action — Tooltip).

Badge: overlay up to four characters via action.setBadgeText() and action.setBadgeBackgroundColor(). There is no manifest default for badges (browser.action — Badge).

Per-tab state: pass tabId in action API setters; tab-specific values override global ones (browser.action — Per-tab state).

Enabled vs disabled: default_state in the manifest can start the action disabled; use action.enable() / action.disable(). Disabled actions stay visible but clicks open the context menu instead of running the popup or onClicked (Implement an action — Activate the action conditionally).

declarativeContent: enable the action on matching pages without host permissions

Section titled “declarativeContent: enable the action on matching pages without host permissions”

In Manifest V2, page actions were greyed out when irrelevant and browser actions were always “on.” Manifest V3 merges these into one action API (Replace Browser Actions and Page Actions with Actions).

The Declarative Content API lets you enable your extension’s action depending on the URL of a web page, or if a CSS selector matches an element on the page, without needing to add host permissions or inject a content script.

— Chrome, browser.declarativeContent

Use declarativeContent.ShowAction (not deprecated ShowPageAction) inside onPageChanged rules. When conditions fail, the toolbar action is greyscale; clicking opens the extensions context menu instead of your popup (browser.declarativeContent — ShowAction).

Typical pattern from the Action API docs (Emulate actions with declarativeContent):

  1. On install, action.disable() globally.
  2. Add rules with PageStateMatcher (for example hostSuffix: '.example.com').
  3. Attach new browser.declarativeContent.ShowAction() to enable the icon on matching tabs.

Pair with activeTab when you need to touch page content after the user clicks the now-enabled action (browser.declarativeContent — Concepts).

Manifest V2 browser_action and page_action vs V3 action

Section titled “Manifest V2 browser_action and page_action vs V3 action”
Manifest V2 Manifest V3
browser_action / page_action single action key
chrome.browserAction / chrome.pageAction chrome.action
pageAction.show() / hide() per tab enable() / disable() with tabId, or declarative rules

Browser actions and page actions were separate concepts in Manifest V2. … In Manifest V3, these concepts are consolidated into the Action API.

— Chrome, Update your code

MV2 guidance still helps conceptually: use features that apply on most pages as a always-available toolbar control; limit UI to some pages via declarative rules or dynamic enablement (Design the user interface, chrome.browserAction — Tips).

  1. Load the unpacked extension, pin the action icon, and confirm click behaviour matches your design—popup vs bare click—using the steps in Hello World extension.

  2. On a page where your declarative rule should apply, verify the icon is full color and opens the popup or handler; on other pages confirm it is greyscale and shows the context menu when clicked (browser.declarativeContent — ShowAction).

  3. Open chrome://extensions, confirm 48×48 (and related) icons from the icons key render correctly on the management page (Manifest — Icons).

  4. For automated popup testing, follow End-to-end testing for Chrome Extensions (action.openPopup() or open popup.html in a tab with a test tabId query param).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about so it can be corrected.