# 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="/files/kHz6ssCPNs0xSJ1NAxNH" 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="/files/gxdY2SsamdGc9KU9NLYd" 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
