Change "+ New Topic" button to match styling of "Reply" button

AI-generated summary

In a Support discussion titled Change “+ New Topic” button to match styling of “Reply” button, jord8on requested to style the “+ New Topic” button to visually match the “Reply” button using the site’s Tertiary color. Stranik provided CSS code to override the button’s background, text, and SVG icon colors, including hover states, and linked to Discourse’s theme documentation. jord8on appreciated the help and asked how to minify two separate CSS blocks targeting different “+ New Topic” buttons (header vs. category/tag pages). Stranik suggested combining selectors or using IDs like #new-create-topic, though noted uncertainty about uniqueness. When jord8on reported an issue with the plus icon color on hover, Stranik recommended explicitly targeting the SVG inside the hover state: #new-create-topic:hover > svg. Ultimately, jord8on opted to keep the original two code snippets for reliability. The thread highlights CSS customization flexibility in Discourse themes and the importance of testing hover states for icons.

I like the styling of the “Reply” button, which is the “Tertiary” color as defined in /admin/customize/colors (Color Palettes/selection)

I would like to have our “New Topic” button match the styling of the “Reply” button as illustrated in this video:

You can try taking the CSS of the reply button and transferring these properties to the add post button:

background: #00a3cc;
color: #fff;

Try adding this:

 .header-buttons .btn.btn-default {
      background: #00a3cc;
      color: #fff;
  }

  .header-buttons .btn.btn-default svg {
      color: #fff !important;
  }

Next, you need to add css for :hover (hover)


  .header-buttons .btn.btn-default:hover {
      background: #***;
  }

Select the necessary colors more accurately. Replace *** with the color you want.

How to add css to Discourse:

You can do this with any part of css.

Fantastic answer!!! Thank you so much!

I could use one more bit of CSS advice… how could I best minify these two bits of code?:

Change color of [+ New Topic] button in header

This header button exists because of (+ New topic) button on all pages Theme

.header-buttons .btn.btn-default {
      background: #00ccff;
      color: #fff;
      font-weight: 600;
  }
.header-buttons .btn.btn-default svg {
      color: #fff !important;
  }
.header-buttons .btn.btn-default:hover {
      background: #00a3cc;
  }

Change color of [+ New Topic] button in on category and tag pages

button#create-topic {
      background: #00ccff;
      color: #fff;
      font-weight: 600;
  }
button#create-topic svg {
      color: #fff !important;
  }
button#create-topic:hover {
      background: #00a3cc;
  }

Minimize? I’m not sure about the translation, I apologize. Try combining this:

.header-buttons .btn.btn-default, .header-buttons .btn.btn-default svg {
      background: #00ccff;
      color: #fff !important;
      font-weight: 600;
  }
.header-buttons .btn.btn-default:hover {
      background: #00a3cc;
}

Or

#new-create-topic, #new-create-topic svg {
    background: #00ccff;
    color: #fff !important;
    font-weight: 600;
}

#new-create-topic:hover {
    background: #00a3cc;
}

I look there is id (new-create-topic), I do not know how unique it is. Try using this (I did not check).

There are actually many options.

Use:

  • .header-buttons
  • button
  • #new-create-topic

Any combination of them…

Thanks for trying to help make the code shorter. When I tried several combinations like the ones you suggested, this is what I would get… (notice the plus sign)

hoverstate

For now I just decided to keep the two code snippets and everything is perfect!! Thanks again @Stranik

We did not set css for the icon on hover:

#new-create-topic:hover, #new-create-topic:hover > svg {
    background: #00a3cc;
}

Perhaps so. Sometimes it’s easier to do locally and see. :slightly_smiling_face:

You can safely try different options, combine them. There is a big field for creativity. Good luck!