Role-based menu items

You can easily control which menu items (Menu/Horizontal menu/Context menu button) users can access based on their roles. Modify the example below and use it as an Items parameter in JS mode.

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;

Last updated