| 1 |
--- |
| 2 |
id: Navigation |
| 3 |
section: components |
| 4 |
cssPrefix: pf-v6-c-nav |
| 5 |
propComponents: ['Nav', 'NavList', 'NavGroup', 'NavItem', 'NavItemSeparator', 'NavExpandable'] |
| 6 |
ouia: true |
| 7 |
--- |
| 8 |
|
| 9 |
import { useState } from 'react'; |
| 10 |
import './nav.css'; |
| 11 |
import RhMicronsCaretRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-right-icon'; |
| 12 |
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; |
| 13 |
import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon'; |
| 14 |
import FolderOpenIcon from '@patternfly/react-icons/dist/esm/icons/folder-open-icon'; |
| 15 |
import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon'; |
| 16 |
import RhUiLinkIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-link-icon'; |
| 17 |
|
| 18 |
## Examples |
| 19 |
|
| 20 |
### Default |
| 21 |
|
| 22 |
```ts file="./NavDefault.tsx" |
| 23 |
|
| 24 |
``` |
| 25 |
|
| 26 |
### Grouped |
| 27 |
|
| 28 |
The following example shows two navigation groups, each with a `title` prop passed into the nav group component. To keep nav groups accessible an `aria-label` must be passed in if the `title` prop is not passed in. |
| 29 |
|
| 30 |
```ts file="./NavGrouped.tsx" |
| 31 |
|
| 32 |
``` |
| 33 |
|
| 34 |
### Expandable |
| 35 |
|
| 36 |
```ts file="./NavExpandable.tsx" |
| 37 |
|
| 38 |
``` |
| 39 |
|
| 40 |
### Expandable third level |
| 41 |
|
| 42 |
```ts file="./NavExpandableThirdLevel.tsx" |
| 43 |
|
| 44 |
``` |
| 45 |
|
| 46 |
### Mixed |
| 47 |
|
| 48 |
```ts file="./NavMixed.tsx" |
| 49 |
|
| 50 |
``` |
| 51 |
|
| 52 |
### Horizontal navigation |
| 53 |
|
| 54 |
```ts file="./NavHorizontalNav.tsx" |
| 55 |
|
| 56 |
``` |
| 57 |
|
| 58 |
### Horizontal subnav |
| 59 |
|
| 60 |
```ts file="./NavHorizontalSubNav.tsx" |
| 61 |
|
| 62 |
``` |
| 63 |
|
| 64 |
### Flyout |
| 65 |
|
| 66 |
A flyout should be a `Menu` component. Press `space` or `right arrow` to open a flyout using the keyboard, use the arrow keys to navigate between flyout items, and press `escape` or `left arrow` to close a flyout. |
| 67 |
|
| 68 |
```ts file="./NavFlyout.tsx" |
| 69 |
|
| 70 |
``` |
| 71 |
|
| 72 |
### Drilldown |
| 73 |
|
| 74 |
```ts file="./NavDrilldown.tsx" |
| 75 |
|
| 76 |
``` |
| 77 |
|
| 78 |
### With icons |
| 79 |
|
| 80 |
```ts file="./NavIcons.tsx" |
| 81 |
|
| 82 |
``` |
| 83 |
|
| 84 |
|
| 85 |
## Types |
| 86 |
|
| 87 |
### NavSelectClickHandler |
| 88 |
|
| 89 |
The NavItem `onClick` prop accepts the `NavSelectClickHandler` type, which is made up of the following argument and return types: |
| 90 |
|
| 91 |
```noLive |
| 92 |
( |
| 93 |
event: React.FormEvent<HTMLInputElement>, |
| 94 |
itemId: number | string, |
| 95 |
groupId: number | string, |
| 96 |
to: string |
| 97 |
) => void; |
| 98 |
``` |