theme.update()

Updates the browser theme according to the content of given Theme object.

Syntax

browser.theme.update(
  windowId,    // integer
  theme        // object
)

Parameters

windowId Optional
integer. The ID of a window. If this is provided, the theme is applied only to that window. If it is omitted the theme is applied to all windows.
theme
object. A Theme object specifying values for the UI elements you want to modify.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
Basic supportChrome No support NoEdge No support NoFirefox Full support 55Opera No support NoFirefox Android No support No
windowIdChrome No support NoEdge No support NoFirefox Full support 57Opera No support NoFirefox Android No support No

Legend

Full support  
Full support
No support  
No support

Examples

Sets the browser theme to use a sun graphic with complementary background color:

const suntheme = {
 images: {
   headerURL: 'sun.jpg',
 },
 colors: {
   accentcolor: '#CF723F',
   textcolor: '#111',
 }
};

browser.theme.update(suntheme);

Set the theme for just the currently focused window:

const day = {
    images: {
      headerURL: 'sun.jpg',
    },
    colors: {
      accentcolor: '#CF723F',
      textcolor: '#111',
    }
};

browser.menus.create({
  id: "set-theme",
  title: "set theme",
  contexts: ["all"]
});

async function updateThemeForCurrentWindow() {
  let currentWindow = await browser.windows.getLastFocused();
  browser.theme.update(currentWindow.id, day);
}

browser.menus.onClicked.addListener(updateThemeForCurrentWindow);

Example extensions

Document Tags and Contributors

Contributors to this page: hellosct1, ntim, wbamberg, rebloor
Last updated by: hellosct1,