docs.rodeo

MDN Web Docs mirror

theme.update()

{{AddonSidebar}} 

Updates the browser theme according to the content of the {{WebExtAPIRef("theme.Theme", "Theme")}}  object.

To use this method, an extension must request the “theme” permission in its manifest.json file.

Syntax

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

Parameters

Examples

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

const sunTheme = {
  images: {
    theme_frame: "sun.jpg",
  },
  colors: {
    frame: "#CF723F",
    tab_background_text: "#111",
  },
};

browser.theme.update(sunTheme);

Set the theme for the focused window only:

const day = {
  images: {
    theme_frame: "sun.jpg",
  },
  colors: {
    frame: "#CF723F",
    tab_background_text: "#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);

{{WebExtExamples}} 

Browser compatibility

{{Compat}} 

In this article

View on MDN