Jump to content

Guides

Dropdown Menus

Description

Dropdown menus allow users to select from a number of options. The markup is designed to work in tandem with the ips.ui.menu javascript module.

 

Usage

A menu consists of a trigger element, and the menu element itself:

<!-- The trigger -->
<a href='#elMyMenu_menu' id='elMyMenu'>Open Menu</a>

<!-- The menu -->
<ul id='elMyMenu_menu' class='ipsMenu'>
	...
</ul>

The ID of the menu should be the ID of the trigger element, suffixed by _menu. If the trigger element is a link, its href should be an anchor to the ID of the menu element. This makes the menu accessible even when Javascript is disabled in the browser.

 

Basic menu

A basic menu might have the following markup:

<ul class='ipsMenu ipsHide'>
	<li class='ipsMenu_item'><a href='#'>Item 1</a></li>
	<li class='ipsMenu_item'><a href='#'>Item 2</a></li>
	<li class='ipsMenu_item'><a href='#'>Item 3</a></li>
	<li class='ipsMenu_sep'><hr></li>
	<li class='ipsMenu_item'><a href='#'>Item 4</a></li>
	<li class='ipsMenu_item'><a href='#'>Item 5</a></li>
</ul>

This would display as follows: see example.

ipsMenu is the base class for the menu element. Items within the menu should have the class ipsMenu_item, with the link element inside of that. A separator item can be added by giving the item the class ipsMenu_sep, containing an <hr> element.

Note that the positioning and stem is added automatically by the menu javascript module; it does not need to be manually specified. The stem can be removed, if necessary, by including the class ipsMenu_noStem on the menu element.

 

Disabling menu items

Individual menu items can be disabled by adding the class ipsMenu_itemDisabled to the list item: see example.

Note: Disabled items are not foolproof; in browsers that do not support the CSS pointer-events style, a click on a disabled item will still register. Ensure your javascript properly deals with disabled item clicks if necessary.

 

Menu sizing

By default, a menu will have no defined width. An additional classname can be specified on the menu element to determine how wide it should display.

  • ipsMenu_auto - menu will appear as wide as necessary, though with a minimum width of 200px and a maximum width of 500px
  • ipsMenu_narrow - 200 pixels wide
  • ipsMenu_normal - 300 pixels wide
  • ipsMenu_wide - 450 pixels wide

 

Selectable menus

A selectable menu allows the user to toggle one or more of the menu items, useful for turning options on and off. For this functionality to work, the javascript module needs to be used.

A menu can be made selectable by adding the classname ipsMenu_selectable. A menu item can be shown as selected by adding the classname ipsMenu_itemChecked to the list item.

The markup for a selectable menu might look this:

<ul id='elMenu2_menu' class='ipsMenu ipsMenu_normal ipsMenu_selectable ipsHide'>
	<li class='ipsMenu_item'><a href='#'>Item 1</a></li>
	<li class='ipsMenu_item ipsMenu_itemChecked'><a href='#'>Item 2</a></li>
	<li class='ipsMenu_item'><a href='#'>Item 3</a></li>
</ul>

This would display as follows: see example.

 

Sub-menus

Submenus can be created by embedding menus within one another. To do so, simply include the ipsMenu_subItems class on the item that contains the submenu, and the submenu itself within the item. For example:

<ul id='elMenu3_menu' class='ipsMenu ipsMenu_normal ipsHide'>
	<li class='ipsMenu_item'>
		<a href='#'>Item 1 (no children)</a>
	</li>
	<li class='ipsMenu_item ipsMenu_subItems'>
		<a href='#'>Item 2 (with children)</a>
		<ul class='ipsMenu ipsMenu_wide ipsHide'>
			<li class='ipsMenu_item'><a href='#'>Sub Item 1</a></li>
			<li class='ipsMenu_item'><a href='#'>Sub Item 2</a></li>
			<li class='ipsMenu_item'><a href='#'>Sub Item 3</a></li>
		</ul>
	</li>
</ul>

This would display as follows: see example.

 


  Report Guide


×