Skip to content

Instantly share code, notes, and snippets.

require("sdk/preferences/service").set("javascript.options.strict", false);
var { ActionButton } = require('sdk/ui/button/action');
var { Toolbar } = require("sdk/ui/toolbar");
var { Frame } = require("sdk/ui/frame");
var button = ActionButton({
id: "my-button",
label: "my button",
icon: {
var { Toolbar } = require("sdk/ui/toolbar");
var { Frame } = require("sdk/ui/frame");
var frame1 = new Frame({
url: 'data:text/html;charset=utf-8,blah'
});
var toolbar = Toolbar({
title: "My toolbar",
items: [frame1]
var { ToggleButton } = require("sdk/ui/button/toggle");
var toggle = ToggleButton({
id: "my-button",
label: "my button",
icon: {
"16": "./firefox-16.png",
"32": "./firefox-32.png"
}
});
var { ToggleButton } = require("sdk/ui/button/toggle");
var button = ToggleButton({
id: "my-button",
label: "default",
icon: {
"16": "./firefox-16.png",
"32": "./firefox-32.png"
},
onClick: updateLabelForThisWindow
var { ToggleButton } = require("sdk/ui/button/toggle");
var { ActionButton } = require("sdk/ui/button/action");
var toggleButton = ToggleButton({
id: "my-toggle-button",
label: "toggle-default",
icon: {
"16": "./firefox-16.png",
"32": "./firefox-32.png"
},
let mdnRequest = require("sdk/request").Request({
url: "https://developer.mozilla.org/en-US/search.json?q=" + currentCssProperty + "&topic=css",
onComplete: showTheDocSummary
});
mdnRequest.get();
...
function showTheDocSummary(response) {

Getting started

Prerequisites

To create add-ons for Firefox using the SDK, you'll first need to follow the instructions to install and activate the SDK. Installation is something you only need to do once: activation is something you need to do for each command prompt you open.

Once you've done that, you'll be looking at a command prompt.

If you're on Linux or Mac OS X, the prompt should start with the name of the SDK's root directory:

var { Frame } = require("sdk/ui/frame");
var { Toolbar } = require("sdk/ui/toolbar");
/*
<head>
</head>
<body>
<input id="button" type="button" value="click me">
<script type="text/javascript">
var { ActionButton } = require('sdk/ui/button/action');
var panels = require("sdk/panel");
var self = require("sdk/self");
var button = ActionButton({
id: "my-button",
label: "my button",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
const defaultState = {
"label": "default label",
"icon": "./default.png",
}
const differentState = {
"label": "different label",
"icon": "./different.png",
}