YUI recommends YUI3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

This documentation is no longer maintained.

YUI Library Examples: Menu Family: Application Menubar

Menu Family: Application Menubar

This example demonstrates how to use the MenuBar widget to create a menu bar entirely from JavaScript that functions like one found in a traditional desktop application.

Begin by defining an array of MenuItem configuration properties that describe each item in the MenuBar.

Next use the onDOMReady method of the Event utility to instantiate the MenuBar as soon as the page's DOM is available for scripting.

The "lazyload" property is set to "true" to help speed up the initial load time of the MenuBar instance by deferring the initialization and rendering of each submenu until just before it is initially made visible. The "itemdata" property is set to the array of MenuItem configuration properties; each item in the array will be used to add a new item to the MenuBar when it is rendered.

Often the first item in a menu bar has an icon as its label, but no text. It is easy to achieve this using CSS, while still ensuring the text of the MenuItem is available to users of a screen reader.

Start by wrapping the MenuItem's text label in an <em> element. Next, give the <em> a fixed width, and set the "text-indent" property to a value that pushes the text beyond the boundaries of element as defined by the width. Use the "overflow" property to hide the text. Lastly, apply an image to the MenuItem instance via the "background" property.

Menu Family Examples:

More Menu Family Resources:

Copyright © 2013 Yahoo! Inc. All rights reserved.

Privacy Policy - Copyright Policy - Job Openings