| 1 |
--- |
| 2 |
id: Custom menus |
| 3 |
section: components |
| 4 |
subsection: menus |
| 5 |
--- |
| 6 |
|
| 7 |
import { cloneElement, Fragment, useEffect, useRef, useState } from 'react'; |
| 8 |
|
| 9 |
import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon'; |
| 10 |
import RhUiBranchFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-branch-fill-icon'; |
| 11 |
import RhUiStorageDomainFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-storage-domain-fill-icon'; |
| 12 |
import RhUiServerStackFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-server-stack-fill-icon'; |
| 13 |
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; |
| 14 |
import RhUiMenuBarsIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-menu-bars-icon'; |
| 15 |
import RhUiClipboardFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-clipboard-fill-icon'; |
| 16 |
import RhUiNotificationFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-notification-fill-icon'; |
| 17 |
import RhUiThumbnailViewSmallFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-thumbnail-view-small-fill-icon'; |
| 18 |
import brandImg from '../assets/PF-IconLogo.svg'; |
| 19 |
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; |
| 20 |
import RhMicronsCaretDownFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-down-fill-icon'; |
| 21 |
import RhMicronsCloseIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-close-icon'; |
| 22 |
import avatarImg from '../assets/avatarImg.svg'; |
| 23 |
import { css } from '@patternfly/react-styles'; |
| 24 |
import styles from '@patternfly/react-styles/css/components/Menu/menu'; |
| 25 |
import text from '@patternfly/react-styles/css/utilities/Text/text'; |
| 26 |
|
| 27 |
## Examples |
| 28 |
|
| 29 |
Custom menus can be constructed using a composable approach by combining the [menu](/components/menus/menu) and [menu toggle](/components/menus/menu-toggle) components in unique ways. To handle basic keyboard inputs, [dropdown](/components/menus/dropdown), [select](/components/menus/select), or [`<MenuContainer>`](/components/menus/menu#menucontainer) components may be used in combination with menu components. |
| 30 |
|
| 31 |
Additionally, menu components may be connected to each other manually through our undocumented internal [popper.js](https://popper.js.org/) wrapper component called Popper. |
| 32 |
|
| 33 |
### With actions |
| 34 |
|
| 35 |
```ts file="./examples/ActionsMenuDemo.tsx" |
| 36 |
|
| 37 |
``` |
| 38 |
|
| 39 |
### With favorites |
| 40 |
|
| 41 |
```ts file="./examples/FavoritesDemo.tsx" |
| 42 |
|
| 43 |
``` |
| 44 |
|
| 45 |
### With drilldown |
| 46 |
|
| 47 |
```ts file="./examples/DrilldownMenuDemo.tsx" |
| 48 |
|
| 49 |
``` |
| 50 |
|
| 51 |
### With inline search filter |
| 52 |
|
| 53 |
```ts file="./examples/InlineSearchFilterMenuDemo.tsx" |
| 54 |
|
| 55 |
``` |
| 56 |
|
| 57 |
### Tree view menu |
| 58 |
|
| 59 |
When rendering a menu-like element that does not contain `<MenuItem>` components, [panel](/components/panel) allows more flexible control and customization. |
| 60 |
|
| 61 |
```ts file="./examples/TreeViewMenuDemo.tsx" |
| 62 |
|
| 63 |
``` |
| 64 |
|
| 65 |
### Flyout menu |
| 66 |
|
| 67 |
The flyout will automatically position to the left or top if it would otherwise go outside the window. The menu must be placed in a container outside the main content like Popper, [popover](/components/popover) or [tooltip](/components/tooltip), since it may go over the side nav. |
| 68 |
|
| 69 |
```ts file="./examples/FlyoutDemo.tsx" |
| 70 |
|
| 71 |
``` |
| 72 |
|
| 73 |
### Application launcher menu |
| 74 |
|
| 75 |
```ts file="./examples/ApplicationLauncherDemo.tsx" |
| 76 |
|
| 77 |
``` |
| 78 |
|
| 79 |
### Context selector menu |
| 80 |
|
| 81 |
```ts file="./examples/ContextSelectorDemo.tsx" |
| 82 |
|
| 83 |
``` |
| 84 |
|
| 85 |
### Date select menu |
| 86 |
|
| 87 |
```ts file="./examples/DateSelectDemo.tsx" |
| 88 |
|
| 89 |
``` |