# 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&#x26;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&#x26;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.
