Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:49:15+00:00 2026-05-23T01:49:15+00:00

I’m trying to display a small text (new messages count) over icon in toolbar

  • 0

I’m trying to display a small text (new messages count) over icon in toolbar button, something like Chrome and Opera extensions have with badge over the toolbar icons. Text should not cover the whole icon, it should be at the bottom so the user can still see main part of the icon and recognize what extension it is. How can I do this?

You can see what I want on this example image from Chrome:

toolbar button text overlay on chrome

I tried with description, span and div inside stack element but I couldn’t get none of them to position at the bottom. Description and div always display text at the center, while span displays it on the right side of the icon making the entire button wider.

<toolbarpalette id="BrowserToolbarPalette">
    <toolbarbutton class="toolbarbutton-1">
        <stack>
            <image></image>
            <description right="0" bottom="0" value="4"></description>
            <!-- <html:div right="0" bottom="0">5</html:div> -->
        </stack>
    </toolbarbutton>
</toolbarpalette>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:49:15+00:00Added an answer on May 23, 2026 at 1:49 am

    I had some time to waste while waiting for rain to stop in Formula 1, so I made this work with canvas:

    UPDATED: Previous method was flawed when user would remove the icon from the toolbar, updated method is more robust and with less code.

    XUL

    <overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
        <hbox hidden="true">
            <html:canvas id="toolbar_button_canvas" width="24" height="24"></html:canvas>
        </hbox>
        <toolbarpalette id="BrowserToolbarPalette">
            <toolbarbutton id="toolbar_button" class="toolbarbutton-1" />
        </toolbarpalette>
    </overlay>
    

    CSS

    #toolbar_button {
        list-style-image:url("chrome://your_extension/skin/icon_024.png");
    }
    
    toolbar[iconsize="small"] #toolbar_button {
        list-style-image:url("chrome://your_extension/skin/icon_016.png");
    }
    

    JavaScript

    show_status: function(display_text)
    {
        var btn = document.getElementById("toolbar_button");
        var canvas = document.getElementById("toolbar_button_canvas");
        var img_src = window.getComputedStyle(btn).listStyleImage.replace(/^url\("(chrome:\/\/your_extension\/skin\/icon_0\d{2}.png)"\)$/, "$1");   // get image path
        var csize = img_src.replace(/^chrome:\/\/your_extension\/skin\/icon_0(\d{2})\.png$/, "$1"); // get image size
    
        canvas.setAttribute("width", csize);
        canvas.setAttribute("height", csize);
        var ctx = canvas.getContext("2d");
    
        var img = new Image();
        img.onload = function()
        {
            ctx.textBaseline = "top";
            ctx.font = "bold 9px sans-serif";       // has to go before measureText
    
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            ctx.drawImage(img, 0, 0);
    
            if (display_text !== "")
            {
                var w = ctx.measureText(display_text).width;
                var h = 7;                  // 9 = font height
    
                var rp = ((canvas.width - 4) > w) ? 2 : 1;  // right padding = 2, or 1 if text is wider
                var x = canvas.width - w - rp;
                var y = canvas.height - h - 1;          // 1 = bottom padding
    
                ctx.fillStyle = "#f00";             // background color
                ctx.fillRect(x-rp, y-1, w+rp+rp, h+2);
                ctx.fillStyle = "#fff";             // text color
                ctx.fillText(display_text, x, y);
                //ctx.strokeText(display_text, x, y);
            }
            btn.image = canvas.toDataURL("image/png", "");  // set new toolbar image
        };
        img.src = img_src;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
i want to parse a xhtml file and display in UITableView. what is the
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.