# Class connector for adding button to post

**URL:** https://meta.discourse.org/t/class-connector-for-adding-button-to-post/167089
**Category:** Development
**Created:** [October 13, 2020, 1:33pm UTC](https://meta.discourse.org/t/class-connector-for-adding-button-to-post/167089 "2020-10-13T13:33:26Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [October 13, 2020, 2:03pm UTC](https://meta.discourse.org/t/class-connector-for-adding-button-to-post/167089/2 "2020-10-13T14:03:12Z")

</div>

If you want to add a button to the post menu then you’ll need something a little bit different since posts are [widgets](https://meta.discourse.org/t/a-tour-of-how-the-widget-virtual-dom-code-in-discourse-works/40347).

You would need to add something like this to your theme / plugin.

```javascript
api.addPostMenuButton("my-button", () => {
  return {
    action: "someAction",
    icon: "someIcon",
    className: "someClass",
    title: "some title",
  };
});

```

The plugin API has a method for adding new buttons that makes this relatively easy.

[discourse/app/assets/javascripts/discourse/app/lib/plugin-api.js at 7a2e8d3ead63c7d99e1069fc7823e933f931ba85 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/7a2e8d3ead63c7d99e1069fc7823e933f931ba85/app/assets/javascripts/discourse/app/lib/plugin-api.js#L371-L392)

This theme component uses that method to add a new button to that menu based on some conditions and defines a new action, so have a look here

[GitHub - discourse/raw-post-button · GitHub](https://github.com/discourse/raw-post-button)

---

_[View the full topic](https://meta.discourse.org/t/class-connector-for-adding-button-to-post/167089)._
