Search results

Accessibility

ARIA attributes

The web accessibility makes web content and web applications more accessible for people with disabilities. It especially helps in dynamic content change and development of advanced user interface controls with AJAX, HTML, JavaScript, and related technologies. The menu provides a built-in compliance with WAI-ARIA specifications. The WAI-ARIA support is achieved using the attributes such as aria-orientation, aria-label, aria-expanded, aria-disabled, and aria-haspopup applied for menu item in menu. It helps the people with disabilities by providing information about the widget for assistive technology in the screen readers. The menu component contains the menubar, menu, and menuItem roles.

Properties Functionality
menubar This role will be specified for root menu.
menu This role will be specified for an item that have sub menu.
menuitem This role will be specified for an item that do not have sub menus.
aria-haspopup Indicates the availability and type of interactive popup element.
aria-expanded Indicates whether the subtree can be expanded or collapsed, and indicates whether its current state can be expanded or collapsed.
aria-orientation Indicates whether the orientation is horizontal or vertical. The default orientation is horizontal.
aria-label Indicates the menu item text.
aria-disabled Indicates the state of menu item whether it is disabled.

User interaction with keyboard

Keyboard shortcuts Actions
Esc Closes the sub menu that contains focus and returns focus to the parent element.
Enter Opens the sub menu if focused menu item has sub menu, and places focus on its first item or activates the item and closes the sub menu.
Up Navigates up or to the previous menu item.
Down Navigates down or to the next menu item.
Left Closes the current sub menu and navigates to the parent menu.
Right Navigates and open the next sub menu.
Home Focuses the first item.
End Focuses the last item.
razor
Accessibility.cs
@Html.EJS().Menu("menu").Items(ViewBag.menuItems).Render()

<style>
    body {
        margin-top: 100px;
        text-align: center;
    }
</style>
public ActionResult Index()
{
    // Multi Level Menu
    List<object> menuItems = new List<object>();
    menuItems.Add(new
    {
        text = "Fashion",
        items = new List<object>()
        {
            new {
                text = "Men Fashion",
                items = new List<object>()
                {
                    new {
                        text = "Personal Care",
                                items = new List<object>()
                                {
                                    new {
                                        text = "Trimmers"
                                    },
                                    new {
                                        text = "Shavers"
                                    }
                                }
                            },
                            new {
                                text = "Clothing",
                                items = new List<object>()
                                {
                                    new {
                                        text = "Shirts"
                                    },
                                    new {
                                        text = "Jackets"
                                    },
                                    new {
                                        text = "Track Suits"
                                    }
                                }
                            },
                            new { text = "Footwear"}
                        }
                    },
                    new {
                        text = "Women Fashion",
                        items = new List<object>()
                        {
                            new {
                                text = "Clothing",
                                 items = new List<object>()
                                {
                                    new {
                                        text = "Kurtas"
                                    },
                                    new {
                                        text = "Salwars"
                                    },
                                    new {
                                        text = "Sarees"
                                    }
                                }

                            },
                            new {
                                text = "Jewellery",
                                 items = new List<object>()
                                {
                                    new {
                                        text = "Nosepins"
                                    },
                                    new {
                                        text = "Anklets"
                                    }
                                }
                            }
                        }
                    }
                }
    });
    menuItems.Add(new
    {
        text = "Home & Living",
        items = new List<object>()
                {
                   new {
                          text = "Washing Machine",
                           items = new List<object>()
                           {
                               new {
                                      text = "Fully Automatic"
                                },
                                new {
                                     text = "Semi Automatic"
                                   }
                           }
                       },
                    new {
                         text = "Air Conditioners",
                         items = new List<object>()
                            {
                               new {
                                      text = "Inverter ACs"
                                },
                                new {
                                     text = "Split ACs"
                                   }
                                }
                       }
                    }

    });
    menuItems.Add(new
    {
        text = "Sports",
    });
    menuItems.Add(new
    {
        text = "Gaming",
    });

    ViewBag.menuItems = menuItems;
    return View();
}