# 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="/files/lnY8xZciViwwYATrKVRq" 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="/files/B6Ebv6tvivbBMxUo9lvy" 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: 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/how-tos/components-recipes/adding-context-menu-to-the-avatar.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.
