# Role-based Menu component items

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

UI Bakery gives you the ability to configure specific menu items, for Menu components, which users can access based on their [roles](/concepts/workspace-management/roles-in-ui-bakery.md). \
Below, is an example that you can modify according to the roles in your organization. Once you're ready, switch to *JS mode* in the **Items** property of the Menu component and specify the following code:

```javascript
const userHasAccess = {{user.role}} === 'admin'; // Replace with your actual access condition
const menuItems = [
  {
    title: 'Dashboard',
    route: '/dashboard',
    disabled: false  // This item is always enabled
  },
  {
    title: 'Admin Panel',
    route: '/admin',
    disabled: !userHasAccess  // This item is disabled if the user is not an admin
  }
  // ... other menu items
];

return menuItems;
```

<figure><img src="/files/nfQ3BbWHvQv2VL3WTRrm" alt=""><figcaption></figcaption></figure>


---

# 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/concepts/components/work-with-components/role-based-menu-items.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.
