# How can one add a toggle button to the post menu and implement an action for that toggle button in a Discourse plugin?

**URL:** https://meta.discourse.org/t/how-can-one-add-a-toggle-button-to-the-post-menu-and-implement-an-action-for-that-toggle-button-in-a-discourse-plugin/286835
**Category:** Development
**Created:** [November 28, 2023, 12:34pm UTC](https://meta.discourse.org/t/how-can-one-add-a-toggle-button-to-the-post-menu-and-implement-an-action-for-that-toggle-button-in-a-discourse-plugin/286835 "2023-11-28T12:34:55Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [November 28, 2023, 12:41pm UTC](https://meta.discourse.org/t/how-can-one-add-a-toggle-button-to-the-post-menu-and-implement-an-action-for-that-toggle-button-in-a-discourse-plugin/286835/2 "2023-11-28T12:41:05Z")

</div>

Hi @omppatil perhaps this post might help you get in the right direction:

> [@Class connector for adding button to post](https://meta.discourse.org/t/class-connector-for-adding-button-to-post/167089/2):
>
> 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. 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.…](https://github.com/discourse/discourse/blob/7a2e8d3ead63c7d99e1069fc7823e933f931ba85/app/assets/javascripts/discourse/app/lib/plugin-api.js#L371-L392)

Also if you are new to Discourse plugin programming:

> [@Developing Discourse Plugins - Part 1 - Create a basic plugin](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins/30515):
>
> Building a plugin in Discourse can be really simple, once you learn a couple of quirks. The goal of this post is to create a skeleton plugin and introduce you to the basics. Your development environment Make sure you have a development environment of Discourse running on your computer. I recommend you use [the appropriate setup guide](https://meta.discourse.org/tag/dev-install) and come back when you’re done. plugin.rbtada Use [GitHub - discourse/discourse-plugin-skeleton: Template for Discourse plugins · GitHub](https://github.com/discourse/discourse-plugin-skeleton) to create a complete di…

> [@How can I make my own Discourse plugins?](https://meta.discourse.org/t/how-can-i-make-my-own-discourse-plugins/90032/2):
>
> I’ve only just started but here’s my ‘starter for 10’ to get you going: Read: [these](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-1/30515)[this](https://meta.discourse.org/t/how-to-start-building-stuff-for-discourse-if-youre-newbie-like-myself/45954) Try and read the code on the simplest, [but popular plugins](https://meta.discourse.org/c/plugin/l/top/yearly) and see if you can understand what they are doing (this is not always easy, especially with the complexity of dealing with multiple files and the sometimes brutal functional brevity of javasctipt, but persevere) You need to learn: Lots of Javascript (look no further than @mpj’s [Fun Fun Function excellent & fun (!) videos](https://www.youtube.com/channel/UCO1cgjhGzsSYb1rsB4bFe4Q) (thanks man!)) Lots of …

> [@Learn how to start building stuff for Discourse if you're newbie (like myself)](https://meta.discourse.org/t/learn-how-to-start-building-stuff-for-discourse-if-youre-newbie-like-myself/45954):
>
> There are a few ‘how to start’ guides for working with Discourse already and a wealth of useful info on meta, but I thought it might help to give an insight to the mental processes of starting from little, if any, prior coding experience to building substantial Discourse plugins. Discourse is written by experienced developers and has a large codebase. This can feel intimidating. This intimidation factor can be a significant barrier for novice developers. This is a kind of ‘psychological primer’…

---

_[View the full topic](https://meta.discourse.org/t/how-can-one-add-a-toggle-button-to-the-post-menu-and-implement-an-action-for-that-toggle-button-in-a-discourse-plugin/286835)._
