> 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/how-tos/components-recipes/adding-context-menu-to-the-avatar.md).

# Adding context menu to the Avatar

{% hint style="success" %}
Here, we talk about the [Avatar](/reference/working-with-components/avatar.md) and [Context menu](/reference/working-with-components/context-menu-button.md) components.
{% endhint %}

In this article, we'll show how you can add context menu to the Avatar component in UI Bakery. This option might be useful when you want to allow users to access account-related information and actions when clicking on the user avatar.

{% hint style="info" %}
Note that it is a workaround option - it's not natively supported in UI Bakery.
{% endhint %}

Let's see how you can do that:

1. Add the **Avatar** component to the working area.
2. Next, to hide the **Context menu** component inside the Avatar, set the Condition to *false* in the Show condition section of the component's settings.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FuOU6qzQs7loQSPA3l82v%2FCleanShot%202025-07-08%20at%2016.40.05%402x-min.png?alt=media&amp;token=e3affa48-8c10-4b33-bce0-b62268263055" alt=""><figcaption></figcaption></figure>

3. Now, specify your menu items in the component's *Menu items* field, for example:

```javascript
[
  { id: 'userName', title: {{user.email}}, icon: 'account_box_material' },
  { id: 'logout', title: 'Sign Out', icon: 'exit_to_app_material' },
]
```

4. Next, add the following CSS classes to the components in the *Styling* settings section: *avatar-menu* & *avatar-context-menu*.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2F9T9o2fZMVYFxKhCizxZa%2FCleanShot%202025-07-09%20at%2015.05.05%402x-min.png?alt=media&amp;token=19ab6c10-54ca-49c2-92a3-ebf460ca3233" alt=""><figcaption></figcaption></figure>

4. Now, customize styles for these classes in the *Custom code* tab:

```css
<style>
  .avatar-menu {
  	cursor: pointer;
  }

  .avatar-context-menu {
  	margin-top: -36px;
  }
</style>
```

5. Finally, create a *JavaScript* action and assign it to the Avatar's *On Click* trigger:

```javascript
{{ui.avatarContextMenu.toggle()}}
```

Now, when users click on the avatar, the context menu will be displayed.

{% @arcade/embed flowId="Gx6qEk3c8UdgwzDI8i6W" url="<https://app.arcade.software/share/Gx6qEk3c8UdgwzDI8i6W>" %}


---

# 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/how-tos/components-recipes/adding-context-menu-to-the-avatar.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.
