• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
Add-ons
  1. MDN
  2. Mozilla
  3. Add-ons
  4. Themes
  5. Theme concepts

Theme concepts

In This Article
  1. Static themes
    1. Defining a theme
    2. Static theme approaches
      1. Single image themes
      2. Multiple image themes
    3. Static animated themes
  2. Dynamic themes
  3. Cross browser compatibility

WebExtension based themes in Firefox enable you to change the look of the browser by adding images to the header area of the Firefox browser; this is the area behind the menu bar, toolbars, address bar, search bar, and tab strip.

These theme options can be implemented as static themes (although the theme images themselves may be animated) or as dynamic themes created in a browser extension.

If you have a lightweight theme it will be converted to this new theme format automatically before lightweight themes are deprecated. You do not need to port your theme. However, please feel free to update your themes to use any of the new features described here.

Static themes

Static themes are specified using the same resources as a browser extension: a manifest.json file to define the theme components with those components stored in the same folder as the manifest.json file or a sub folder. These resources are then packed in a zip for publication on addons.mozilla.org (AMO).

A theme and browser extension functionality cannot be defined in one package, such as including a theme to complement an extension. You can, however, programmatically include a theme in an extension using the Theme API. See Dynamic themes.

Defining a theme

To create a theme (in this example a simple, single image theme):

  • Create a folder in a suitable location on your computer.
  • Add the theme image file to the folder:
    <mytheme>
     <your_header_image>.<type>
  • Create a file called manifest.json in the folder and edit its content as follows:
     "theme": {
       "images": {
         "headerURL": "<your_header_image>.<type>"
            },
       "colors": {
         "accentcolor": "#FFFFFF",
         "textcolor": "#000"
       }
     }
    
    Where:
    • "accentcolor": is the heading area background color for your theme.
    • "textcolor": the color of the text in the heading area.
  • Package your theme and submit it to AMO, following these instructions.

Static theme approaches

There are two approaches you can take to theming the header area of Firefox: using a single image or using multiple images. You could combine the two, but it’s easier to treat them separately.

Single image themes

This is the basic or minimal theming option, where you define:

  • a single image, which is anchored to the top right of the header area.
  • A color for the text in the header.

The area your header image needs to fill is a maximum of 200 pixels high. The maximum image width is determined by the resolution of the monitor Firefox is displaying on and how much of the monitor Firefox is using. Practically, this means you would need to allow for a width of up to 5120 pixels wide (for the next generation of 5k monitors). However, rather than creating a very wide image, a better approach is to use a narrower image with a transparent left edge so that it fades to the background color. For example, we could use this image
An image of a weta (the common name for a group of about 70 insect species in the families Anostostomatidae and Rhaphidophoridae, endemic to New Zealand) with the left edge fading to total transparency.
combined with a complementary background color, to create this effect in the header
A single image theme using the weta.png image

See details about this theme in the themes example weta_fade.

Obviously, you can still provide a single wide image if you prefer.

Multiple image themes

As an alternative to creating a single image theme, you have the option to use multiple images. These images can be individually anchored to locations within the header, with the option to apply tiling to each image.

Depending on the effect you want to create you may need to suppress the mandatory "headerURL": image with an empty or transparent image. You would use an empty or transparent image if, for example, you wanted to tile a centrally justified image, such as
An image of a weta (the common name for a group of about 70 insect species in the families Anostostomatidae and Rhaphidophoridae, endemic to New Zealand) with the left and right edges fading to total transparency.
to create this effect
A single image theme using the additional images option to align an image to the center of the heading and tile it.
Here you specify the weta image like this:

    "images": {
      "headerURL": "empty.png",
      "additional_backgrounds": [ "weta_for_tiling.png"]
    },

and the images tiling with:

    "properties": {
      "additional_backgrounds_alignment": [ "top" ],
      "additional_backgrounds_tiling": [ "repeat"  ]
     },

Full details of how to setup this theme can be found in the themes example weta_tiled. Full detais of the alignment and tiling options can be found in the "theme" key description.

Alternatively, you can use multiple images, say combining the original weta image with this one anchored to the left of the header
An image of a weta (the common name for a group of about 70 insect species in the families Anostostomatidae and Rhaphidophoridae, endemic to New Zealand) with the right edge fading to total transparency.
to create this effect
A theme using the additional images option to place two mirrored image to the left and right of the browser header.

Where the images are specified with:

  "images": {
   "headerURL": "empty.png",
   "additional_backgrounds": [ "weta.png", "weta-left.png"]
   },

and their alignment by:

  "properties": {
    "additional_backgrounds_alignment": [ "right top" , "left top" ]
    },

Full details of how to setup this theme can be found in the themes example weta_mirror. Full detais of the alignment options can be found in the "theme" key description.

Static animated themes

It is possible to create an animated theme using an APNG format image, as in the themes example animated. However, remember that rapid animations, such as the one in the example might be too distracting for a practical theme.

You can also animate themes programmatically, which we discuss in Dynamic themes.

Dynamic themes

As an alternative to defining a static theme, you can use the theme API to control the theme used in Firefox from within a browser extension. There are a couple of use cases for this option:

  • To bundle a theme with a browser extension, as an added extra.
  • Create a dynamic theme that changes under programmatic control.

And, obviously, you can combine the two and bundle a programmatically controlled theme with your extension.

Using the theme API is straightforward. First, request "theme" permission in the extension's manifest.json file. Next, you build a JSON object containing the same information you would use in a static theme’s manifest.json, Finally, pass the JSON object in a theme.update() call.

For example, the following code, from the dynamic theme example defines the content for the day and night elements of the dynamic theme:

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

The theme.Theme object is then passed to theme.update() to change the header theme, as in this code snippet from the same example:

function setTheme(theme) {
  if (currentTheme === theme) {
    // No point in changing the theme if it has already been set.
    return;
  }
  currentTheme = theme;
  browser.theme.update(themes[theme]);
 }

If you have not built a browser extension before, check out Your first extension for a step-by-step guide.

Cross browser compatibility

There is currently limited compatibility between themes in the major browsers. Opera takes an entirely different approach, and Microsoft Edge themes are not yet open to developers.

There is some compatibility between Firefox static themes and Chrome themes, providing the ability to port a single header image theme from Firefox to Chrome. This would be done by amending the manifest.json keys as follows:

  • "headerURL": to "theme_frame":
  • "accentcolor": to "frame":
  • "textcolor": to "tab_text":

Noting that "frame": and "tab_text": support RGB color definition only.

So, in the single image theme example (weta_fade) could be supported in Chrome using the following manifest.json file:

 "theme": {
    "images": {
      "theme_frame": "weta.png"
    },
    "colors": {
       "frame": [ 173 , 176 , 159 ],
       "tab_text": [ 0 , 0 , 0 ]
    }
 }

However, there will be a couple of differences:

  • Chrome tiles the “theme_frame”: image from the left of the header area.
  • "tab_text": only affects the text on the highlighted/active tab.

The basic theme example using the Chrome compatible manifest.json keys, showing the differences in how those keys are implemented.

For more information, see the notes on Chrome compatibility.

Document Tags and Contributors

Tags: 
  • add-on
  • Theme
 Contributors to this page: rebloor
 Last updated by: rebloor, Jul 23, 2017, 7:45:15 AM
See also
  1. Browser extensions
  2. Getting started
    1. What are extensions?
    2. Your first extension
    3. Your second extension
    4. Anatomy of an extension
    5. Example extensions
  3. How to
    1. Intercept HTTP requests
    2. Modify a web page
    3. Add a button to the toolbar
    4. Implement a settings page
  4. User interface
    1. Introduction
    2. Toolbar button
    3. Address bar button
    4. Sidebar
    5. Context menu items
    6. Options page
    7. Bundled web pages
    8. Notifications
    9. Address bar suggestions
    10. Developer tools panels
  5. Concepts
    1. Using the JavaScript APIs
    2. Content scripts
    3. Match patterns
    4. Internationalization
    5. Content Security Policy
    6. Native messaging
  6. Porting
    1. Porting a Google Chrome extension
    2. Porting a legacy Firefox extension
    3. Embedded WebExtensions
    4. Comparison with the Add-on SDK
    5. Comparison with XUL/XPCOM extensions
    6. Chrome incompatibilities
    7. Differences between desktop and Android
  7. Firefox workflow
    1. Temporary Installation in Firefox
    2. Debugging
    3. Developing for Firefox for Android
    4. Getting started with web-ext
    5. web-ext command reference
    6. Extensions and the Add-on ID
    7. Publishing your extension
  8. JavaScript APIs
    1. Browser support for JavaScript APIs
    2. alarms
    3. bookmarks
    4. browserAction
    5. browsingData
    6. commands
    7. contextMenus
    8. contextualIdentities
    9. cookies
    10. devtools.inspectedWindow
    11. devtools.network
    12. devtools.panels
    13. downloads
    14. events
    15. extension
    16. extensionTypes
    17. history
    18. i18n
    19. identity
    20. idle
    21. management
    22. notifications
    23. omnibox
    24. pageAction
    25. permissions
    26. privacy
    27. proxy
    28. runtime
    29. sessions
    30. sidebarAction
    31. storage
    32. tabs
    33. theme
    34. topSites
    35. types
    36. webNavigation
    37. webRequest
    38. windows
  9. Manifest keys
    1. applications
    2. author
    3. background
    4. browser_action
    5. chrome_settings_overrides
    6. chrome_url_overrides
    7. commands
    8. content_scripts
    9. content_security_policy
    10. default_locale
    11. description
    12. developer
    13. devtools_page
    14. homepage_url
    15. icons
    16. incognito
    17. manifest_version
    18. name
    19. omnibox
    20. optional_permissions
    21. options_ui
    22. page_action
    23. permissions
    24. protocol_handlers
    25. short_name
    26. sidebar_action
    27. theme
    28. version
    29. web_accessible_resources
  10. Themes
  11. Publishing add-ons
  12. Guides
    1. Signing and distribution overview
    2. Submit an add-on
    3. Creating an appealing listing
    4. Review policies
    5. Developer agreement
    6. Featured add-ons
    7. Contact addons.mozilla.org
  13. Community and support
  14. Channels
    1. Add-ons blog
    2. Add-on forums
    3. Stack Overflow
    4. Development newsgroup
    5. IRC Channel
  15. Legacy add-ons
  16. Legacy technologies
    1. Add-on SDK
    2. Legacy Firefox for Android
    3. Bootstrapped extensions
    4. Overlay extensions