> For the complete documentation index, see [llms.txt](https://docs.uibakery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uibakery.io/reference/working-with-components/context-menu-button.md).

# Context menu

## Overview

The dropdown menu button for executing different actions, for example, app navigation. The component supports both manual and dynamic options configuration, as well as various positioning, adjustment, appearance, and styling options.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2F8bHru51wXlkpl0GUOvz0%2FCleanShot%202025-07-23%20at%2017.51.11%402x-min.png?alt=media&amp;token=fbc4143f-2a75-4860-bd91-0b881a57155e" alt=""><figcaption></figcaption></figure>

### Properties

| Name   | Type     | Description    |
| ------ | -------- | -------------- |
| `name` | `string` | Component name |

### Methods

<table><thead><tr><th width="141.96875">Name</th><th width="221.98828125">Parameters</th><th width="98.43359375">Returns</th><th>Description</th></tr></thead><tbody><tr><td><code>click</code></td><td><code>event?: any</code></td><td><code>void</code></td><td>Trigger click event</td></tr><tr><td><code>setDisabled</code></td><td><code>disabled: boolean</code></td><td><code>void</code></td><td>Disable or enable the component</td></tr><tr><td><code>setMenuItems</code></td><td><code>items: { id: string; title?: string; icon?: string; onlyIcon?: boolean }[]</code></td><td><code>void</code></td><td>Set menu options for component</td></tr><tr><td><code>open</code></td><td>–</td><td><code>void</code></td><td>Open the menu</td></tr><tr><td><code>close</code></td><td>–</td><td><code>void</code></td><td>Close the menu</td></tr><tr><td><code>toggle</code></td><td>–</td><td><code>void</code></td><td>Toggle the menu</td></tr></tbody></table>

### Triggers

<table><thead><tr><th width="191.23828125">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>On Click</strong></td><td>Triggered when the component is clicked</td></tr><tr><td><strong>On Item Click</strong></td><td>Triggered when a menu item is clicked</td></tr><tr><td><strong>On Init</strong></td><td>Triggered when the component is initialized</td></tr></tbody></table>

## Working with the component

### Triggering unique actions based on the selected menu item

UI Bakery allows you to set up unique actions for each selected menu item in the Context menu component. Here's how you can do that:

1. Select the Context menu component and set up its menu items.\
   Make sure each one has a *unique id*, for example, item\_1, item\_2, item\_3, etc.
2. Create your unique actions that you want to be triggered for each item.
3. Next, create another action of the *JavaScript Code* type to trigger specific actions depending on the selected item:

```javascript
if ({{params.id}} === 'item_1') {
  await {{actions.itemOneClick.trigger()}};
  
} else if ({{params.id}} === 'item_2') {
  await {{actions.itemTwoClick.trigger()}};
  
} else if ({{params.id}} === 'item_3') {
  await {{actions.itemThreeClick.trigger()}};

}
```

4. Assign this action to the component's **On Item Click** trigger.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FjVx7Zma6eGUJLIoWWLXJ%2FCleanShot%202025-07-25%20at%2012.27.21%402x-min.png?alt=media&amp;token=ef3cc345-dbd0-412a-a403-310f9a34994b" alt=""><figcaption></figcaption></figure>

When clicking on a menu item, the unique action will be triggered and the `{{params.id}}` variable will contain the value of the selected item id.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uibakery.io/reference/working-with-components/context-menu-button.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
