YUI 3.x Home -

YUI Library Examples: Focus Manager Node Plugin: Accessible Toolbar

Note: This is YUI 3.x. Looking for YUI 2.x?

Focus Manager Node Plugin: Accessible Toolbar

This example illustrates how to create an accessible toolbar using the Focus Manager Node Plugin and Node's support for the WAI-ARIA Roles and States.

Setting Up the HTML

Start with a set of <input> elements. For the purpose of this example, the type attribute of each button will be set to a value of "button" since they won't be responsible for submitting a form. Each <input> is wrapped by two <span>s that serve as decorator elements used to style each button with rounded corners.

Setting Up the CSS

Next, each button in the toolbar is styled with rounded corners using a combination of the CSS border property along with the use of negative margins. An icon is added to each button using a background image. Following the advice of the Exceptional Performance team, this example uses the technique of CSS Sprites, combining all of the icons for each button into a single image to reduce HTTP requests.

Initializing the Focus Manager

With the toolbar markup and CSS in place, retrieve the Node instance representing the toolbar (<div id="toolbar-1">) and call the plug passing in a reference to the Focus Manager Node Plugin as the first argument, and a collection of configuration attributes as the second argument.

The Focus Manager's descendants attribute is set to a value of "input", so that only one button in the toolbar is in the browser's default tab flow. This allows users navigating via the keyboard to use the tab key to quickly move into and out of the toolbar. Once the toolbar has focus, the user can move focus among each button using the left and right arrows keys, as defined by the value of the keys attribute. Lastly, the focusClass attribute is used to apply a class of focus to each <input> when it is focused, making it easy to style the focused state in each of the A-Grade browsers.

Styling Focus

To augment the browser's default styling of the focused state define a CSS selector that adds a background color to the

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings