Add button to top menu

I want to add a button (with a different color) to the top menu, and if possible align right
How can i do this ?

1 Like

Almost, but i want to have this button: Premium

Check here: How to add header menu links

1 Like

check, did this but there is no button …

You’ll have to customize a bit with HTML / CSS to get exactly the look you’re going for. If you have a reference button you want to copy you can often get most of the way there by inspecting using something like Chrome web tools and copying existing styles. Lots of tutorials you can follow + modify as well! Definitely a bit of a learning curve but imo fun to figure out how this stuff works :slight_smile:


Screenshots would be really helpful. It is hard to tell if your theme component is just not active or if you put the code in the wrong place.

1 Like

Show us what you’ve got so far and we’ll help you tweak it. We’re flying blind a bit here…


this is the forum:
and instead of the bleu arrow icon i want a button with Premium (or Donateur)

Try changing the following

    api.decorateWidget('header-icons:before', function (helper) {
        return helper.h('li', [helper.h('a#home-button.icon', {
            href: '',
            title: 'Wordt Donateur'
        }, helper.h('i.fa.fa-arrow-circle-up.home-button-icon.d-icon'))]);


    api.decorateWidget('header-icons:before', function (helper) {
        return helper.h('li', [helper.h('a#home-button', {
            href: '',
            title: 'Wordt Donateur',
            text: 'Wordt Donateur'

With the following CSS

a#home-button {
    border: 1px solid #000;
    padding: 5px;
    border-radius: 3px;
    position: relative;
    display: block;
    margin-top: 5px;



This should do it: ( demo: I have a “Weather” link )
You’ll need to style it with css.


  Discourse.ExternalNavItem = Discourse.NavItem.extend({
    href : function() {
      return this.get('href');

  I18n.translations.en.js.filters.premium = { title: "Premium", help: "Premium account" };

    buildList : function(category, args) {
      var list = this._super(category, args);
      if(!category) {
        list.push(Discourse.ExternalNavItem.create({href: '/my/link.html', name: 'premium'}));
      return list;

1 Like

But that adds it to the Navigation, not the header…

But I guess it isn’t obvious which he wants, as his initial posts says “top menu” which refers to the navigation, but his screenshot and example of where his icon is… is in the header.

My example adds to header menu, not to navigation

You are opening the NavItem class and your Weather example is on the navigation…

oh :blush:

Maybe he wants

<script type="text/discourse-plugin" version="0.4">
api.decorateWidget('header-icons:before', helper => {
    return [
            helper.h('li', [
            helper.h('a#premium-button.icon', {
                href: '/link.html',
                title: 'Premium Content'
            }, helper.h('i.fa.fa-cloud.premium-button-icon.d-icon')),

Close, that is almost what he has now, I provided code that puts text there and makes it more “button-ish” (just a few posts up) :wink: So now he has both … one of the two should do what he wants.


Great @cpradio that works, many thanks!


  1. How and where do you add the icons? I like to use external icons instead of fa
  2. I’m trying to open an external link. Is there a way to add a target so that we use a different window?


I’m trying to achieve the same outcome Header Menu Link - text in button. I used the component from here: Custom Header Links
Am not sure how to work with the component to customize based on this thread, any tips?