|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +title: DropMenu |
| 4 | +description: Toggle contextual overlays for displaying lists of links and more with the Bootstrap dropdown plugin. |
| 5 | +group: Components |
| 6 | +toc: true |
| 7 | +--- |
| 8 | + |
| 9 | +import { DropMenu } from 'boot-cell/source/Navigator/DropMenu'; |
| 10 | +import { Example } from '../../../source/component/Example'; |
| 11 | + |
| 12 | +## Overview |
| 13 | + |
| 14 | +DropMenu are toggleable, contextual overlays for displaying lists of links and more. They're toggled by clicking, not by hovering; this is [an intentional design decision](http://markdotto.com/2012/02/27/bootstrap-explained-dropdowns/). |
| 15 | + |
| 16 | +## Accessibility |
| 17 | + |
| 18 | +The [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/TR/wai-aria/) standard defines an actual [`role="menu"` widget](https://www.w3.org/WAI/PF/aria/roles#menu), but this is specific to application-like menus which trigger actions or functions. <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. |
| 19 | + |
| 20 | +Bootstrap's dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the `role` and `aria-` attributes required for true <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus. Authors will have to include these more specific attributes themselves. |
| 21 | + |
| 22 | +However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual `.dropdown-item` elements using the cursor keys and close the menu with the <kbd>ESC</kbd> key. |
| 23 | + |
| 24 | +## Examples |
| 25 | + |
| 26 | +Wrap the dropdown's toggle (your button or link) and the dropdown menu within `.dropdown`, or another element that declares `position: relative;`. DropMenu can be triggered from `<a>` or `<button>` elements to better fit your potential needs. The examples shown here use semantic `<ul>` elements where appropriate, but custom markup is supported. |
| 27 | + |
| 28 | +### Single button |
| 29 | + |
| 30 | +Any single `.btn` can be turned into a dropdown toggle with some markup changes. Here's how you can put them to work with either `<button>` elements: |
| 31 | + |
| 32 | +<Example> |
| 33 | + <DropMenu |
| 34 | + title="Dropdown button" |
| 35 | + list={[ |
| 36 | + { href: '#', title: 'Action' }, |
| 37 | + { href: '#', title: 'Another action' }, |
| 38 | + { href: '#', title: 'Something else here' } |
| 39 | + ]} |
| 40 | + /> |
| 41 | +</Example> |
| 42 | + |
| 43 | +```javascript |
| 44 | +<DropMenu |
| 45 | + title="Dropdown button" |
| 46 | + list={[ |
| 47 | + { href: '#', title: 'Action' }, |
| 48 | + { href: '#', title: 'Another action' }, |
| 49 | + { href: '#', title: 'Something else here' } |
| 50 | + ]} |
| 51 | +/> |
| 52 | +``` |
| 53 | + |
| 54 | +The best part is you can do this with any button variant, too: |
| 55 | + |
| 56 | +<Example> |
| 57 | + <DropMenu |
| 58 | + buttonKind="danger" |
| 59 | + title="Danger" |
| 60 | + list={[ |
| 61 | + { href: '#', title: 'Action' }, |
| 62 | + { href: '#', title: 'Another action' }, |
| 63 | + { href: '#', title: 'Something else here' }, |
| 64 | + {}, |
| 65 | + { href: '#', title: 'Separated link' } |
| 66 | + ]} |
| 67 | + /> |
| 68 | +</Example> |
| 69 | + |
| 70 | +```javascript |
| 71 | +<DropMenu |
| 72 | + buttonKind="danger" |
| 73 | + title="Danger" |
| 74 | + list={[ |
| 75 | + { href: '#', title: 'Action' }, |
| 76 | + { href: '#', title: 'Another action' }, |
| 77 | + { href: '#', title: 'Something else here' }, |
| 78 | + {}, |
| 79 | + { href: '#', title: 'Separated link' } |
| 80 | + ]} |
| 81 | +/> |
| 82 | +``` |
| 83 | + |
| 84 | +### Split button |
| 85 | + |
| 86 | +<Example> |
| 87 | + <DropMenu |
| 88 | + buttonKind="danger" |
| 89 | + title="Action" |
| 90 | + href="https://web-cell.dev/BootCell/" |
| 91 | + list={[ |
| 92 | + { href: '#', title: 'Action' }, |
| 93 | + { href: '#', title: 'Another action' }, |
| 94 | + { href: '#', title: 'Something else here' }, |
| 95 | + {}, |
| 96 | + { href: '#', title: 'Separated link' } |
| 97 | + ]} |
| 98 | + /> |
| 99 | +</Example> |
| 100 | + |
| 101 | +```javascript |
| 102 | +<DropMenu |
| 103 | + buttonKind="danger" |
| 104 | + title="Action" |
| 105 | + href="https://web-cell.dev/BootCell/" |
| 106 | + list={[ |
| 107 | + { href: '#', title: 'Action' }, |
| 108 | + { href: '#', title: 'Another action' }, |
| 109 | + { href: '#', title: 'Something else here' }, |
| 110 | + {}, |
| 111 | + { href: '#', title: 'Separated link' } |
| 112 | + ]} |
| 113 | +/> |
| 114 | +``` |
0 commit comments