Navigation

Examples

Grouped

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.

Expandable third level

Flyout

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.

Types

The NavItem onClick prop accepts the NavSelectClickHandler type, which is made up of the following argument and return types:

(
  event: React.FormEvent<HTMLInputElement>,
  itemId: number | string,
  groupId: number | string,
  to: string
) => void;

Props

*required
NameTypeDefaultDescription
aria-labelstringAccessible label for the nav when there are multiple navs on the page
childrenReact.ReactNodeAnything that can be rendered inside of the nav
classNamestringAdditional classes added to the container
onSelect( event: React.FormEvent<HTMLInputElement>, selectedItem: { groupId: number | string; itemId: number | string; to: string; } ) => void() => undefinedCallback for updating when item selection changes
onToggle( event: React.MouseEvent<HTMLButtonElement>, toggledItem: { groupId: number | string; isExpanded: boolean; } ) => void() => undefinedCallback for when a list is expanded or collapsed
ouiaIdnumber | stringValue to overwrite the randomly generated data-ouia-component-id.
ouiaSafebooleantrueSet the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false.
variant'default' | 'horizontal' | 'horizontal-subnav'For horizontal navs
*required
NameTypeDefaultDescription
backScrollAriaLabelstring'Scroll back'Aria-label for the back scroll button
childrenReact.ReactNodeChildren nodes
classNamestringAdditional classes added to the list
forwardScrollAriaLabelstring'Scroll foward'Aria-label for the forward scroll button
*required
NameTypeDefaultDescription
childrenReact.ReactNodenullAnything that can be rendered inside of the group
classNamestring''Additional classes added to the container
idstringgetUniqueId()Identifier to use for the section aria label
titlestringTitle shown for the group
*required
NameTypeDefaultDescription
childrenReact.ReactNodeContent rendered inside the nav item.
classNamestringAdditional classes added to the nav item
componentReact.ElementType<any> | React.ComponentType<any>'a'Component used to render NavItems if React.isValidElement(children) is false
flyoutReact.ReactElementFlyout of a nav item. This should be a Menu component. Should not be used if the to prop is defined.
groupIdstring | number | nullnullGroup identifier, will be returned with the onToggle and onSelect callback passed to the Nav component
iconReact.ReactNodeIcon added before the nav item children.
isActivebooleanfalseFlag indicating whether the item is active
itemIdstring | number | nullnullItem identifier, will be returned with the onToggle and onSelect callback passed to the Nav component
onClickNavSelectClickHandlerCallback for item click
onShowFlyout() => voidCallback when flyout is opened or closed
ouiaIdnumber | stringValue to overwrite the randomly generated data-ouia-component-id.
ouiaSafebooleanSet the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false.
preventDefaultbooleanfalseIf true prevents the default anchor link action to occur. Set to true if you want to handle navigation yourself.
styleChildrenbooleantrueWhether to set className on children when React.isValidElement(children)
tostringTarget navigation link. Should not be used if the flyout prop is defined.
zIndexnumber9999z-index of the flyout nav item
*required
NameTypeDefaultDescription
componentNo type info'li'
*required
NameTypeDefaultDescription
titlerequiredReact.ReactNodeTitle content shown for the expandable list
buttonPropsanyAdditional props added to the NavExpandable <button>
childrenReact.ReactNode''Anything that can be rendered inside of the expandable list
classNamestring''Additional classes added to the container
groupIdstring | numbernullGroup identifier, will be returned with the onToggle and onSelect callback passed to the Nav component
idstring''Identifier to use for the section aria label
isActivebooleanfalseIf true makes the expandable list title active
isExpandedbooleanfalseBoolean to programatically expand or collapse section
onExpand(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, val: boolean) => voidallow consumer to optionally override this callback and manage expand state externally. if passed will not call Nav's onToggle.
ouiaIdnumber | stringValue to overwrite the randomly generated data-ouia-component-id.
srTextstring''If defined, screen readers will read this text instead of the list title

CSS variables

Expand or collapse columnSelectorVariableValue
.pf-v6-c-nav--pf-v6-c-nav__link--PaddingBlockStart
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__link--PaddingBlockEnd
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__link--PaddingInlineStart
1rem
.pf-v6-c-nav--pf-v6-c-nav__link--PaddingInlineEnd
1rem
.pf-v6-c-nav--pf-v6-c-nav__list--RowGap
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__list--ColumnGap
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--PaddingBlockStart
1rem
.pf-v6-c-nav--pf-v6-c-nav--PaddingBlockEnd
1rem
.pf-v6-c-nav--pf-v6-c-nav--PaddingInlineStart
0
.pf-v6-c-nav--pf-v6-c-nav--PaddingInlineEnd
0
.pf-v6-c-nav--pf-v6-c-nav--RowGap
1.5rem
.pf-v6-c-nav--pf-v6-c-nav--ColumnGap
0
.pf-v6-c-nav--pf-v6-c-nav--AlignItems
baseline
.pf-v6-c-nav--pf-v6-c-nav--FontSize
0.875rem
.pf-v6-c-nav--pf-v6-c-nav--FontWeight
400
.pf-v6-c-nav--pf-v6-c-nav--LineHeight
1.5
.pf-v6-c-nav--pf-v6-c-nav--OutlineOffset
calc(0.25rem * -1)
.pf-v6-c-nav--pf-v6-c-nav--BackgroundColor
transparent
.pf-v6-c-nav--pf-v6-c-nav__list--ScrollSnapTypeAxis
x
.pf-v6-c-nav--pf-v6-c-nav__list--ScrollSnapTypeStrictness
proximity
.pf-v6-c-nav--pf-v6-c-nav__list--ScrollSnapType
x proximity
.pf-v6-c-nav--pf-v6-c-nav__item--ScrollSnapAlign
end
.pf-v6-c-nav--pf-v6-c-nav__section-title--FontWeight
500
.pf-v6-c-nav--pf-v6-c-nav__section-title--Color
(In light theme) #151515
.pf-v6-c-nav--pf-v6-c-nav__section-title--PaddingBlockStart
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__section-title--PaddingBlockEnd
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__section-title--PaddingInlineStart
1rem
.pf-v6-c-nav--pf-v6-c-nav__section-title--PaddingInlineEnd
1rem
.pf-v6-c-nav--pf-v6-c-nav__item--RowGap
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__item__toggle-icon--Rotate
0
.pf-v6-c-nav--pf-v6-c-nav__item--m-expanded__toggle-icon--Rotate
90deg
.pf-v6-c-nav--pf-v6-c-nav__link--ColumnGap
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__link--AlignItems
baseline
.pf-v6-c-nav--pf-v6-c-nav__link--BorderRadius
6px
.pf-v6-c-nav--pf-v6-c-nav__link--BackgroundColor
(In light theme) rgba(255, 255, 255, 0.0000)
.pf-v6-c-nav--pf-v6-c-nav__link--WhiteSpace
normal
.pf-v6-c-nav--pf-v6-c-nav__link--Color
(In light theme) #4d4d4d
.pf-v6-c-nav--pf-v6-c-nav__link--hover--Color
(In light theme) #151515
.pf-v6-c-nav--pf-v6-c-nav__link--hover--BackgroundColor
(In light theme) #ffffff
.pf-v6-c-nav--pf-v6-c-nav__link--m-current--BackgroundColor
(In light theme) #ffffff
.pf-v6-c-nav--pf-v6-c-nav__link--m-current--Color
(In light theme) #151515
.pf-v6-c-nav--pf-v6-c-nav__link-icon--Color
(In light theme) #707070
.pf-v6-c-nav--pf-v6-c-nav__link--m-current__link-icon--Color
(In light theme) #1f1f1f
.pf-v6-c-nav--pf-v6-c-nav__subnav--RowGap
3px
.pf-v6-c-nav--pf-v6-c-nav__subnav--PaddingInlineStart
1rem
.pf-v6-c-nav--pf-v6-c-nav__scroll-button--BorderColor
(In light theme) #c7c7c7
.pf-v6-c-nav--pf-v6-c-nav__scroll-button--BorderWidth
1px
.pf-v6-c-nav--pf-v6-c-nav__scroll-button--first-of-type--c-button--BorderStartStartRadius
999px
.pf-v6-c-nav--pf-v6-c-nav__scroll-button--first-of-type--c-button--BorderEndStartRadius
999px
.pf-v6-c-nav--pf-v6-c-nav__scroll-button--last-of-type--c-button--BorderStartEndRadius
999px
.pf-v6-c-nav--pf-v6-c-nav__scroll-button--last-of-type--c-button--BorderEndEndRadius
999px
.pf-v6-c-nav--pf-v6-c-nav__toggle--PaddingInlineStart
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__toggle--PaddingInlineEnd
0.5rem
.pf-v6-c-nav--pf-v6-c-nav__toggle--TranslateY
calc((1.5 * 0.875rem / 2) - 50%)
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal__list--PaddingBlockStart
0
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal__list--PaddingBlockEnd
0
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal__list--PaddingInlineStart
0
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal__list--PaddingInlineEnd
0
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-scrollable__list--PaddingInlineStart
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-scrollable__list--PaddingInlineEnd
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav--BackgroundColor
(In light theme) #f2f2f2
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav--BorderRadius
999px
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__list--PaddingBlockStart
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__list--PaddingBlockEnd
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__list--PaddingInlineStart
1rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__list--PaddingInlineEnd
1rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav--m-scrollable__list--PaddingInlineStart
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav--m-scrollable__list--PaddingInlineEnd
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__link--PaddingBlockStart
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__link--PaddingBlockEnd
0.25rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__link--PaddingInlineStart
1rem
.pf-v6-c-nav--pf-v6-c-nav--m-horizontal--m-subnav__link--PaddingInlineEnd
1rem
.pf-v6-c-nav.pf-m-inset--pf-v6-c-nav--PaddingInlineStart
1rem
.pf-v6-c-nav.pf-m-inset--pf-v6-c-nav--PaddingInlineEnd
1rem
.pf-v6-c-nav .pf-v6-c-menu--pf-v6-c-menu--MinWidth
100%
.pf-v6-c-nav .pf-v6-c-menu.pf-m-drilldown--pf-v6-c-menu--PaddingBlockStart
0
.pf-v6-c-nav .pf-v6-c-menu.pf-m-drilldown--pf-v6-c-menu--PaddingBlockEnd
0
.pf-v6-c-nav .pf-v6-c-menu.pf-m-drilldown--pf-v6-c-menu--BackgroundColor
transparent
.pf-v6-c-nav .pf-v6-c-menu.pf-m-drilldown--pf-v6-c-menu--BoxShadow
none
.pf-v6-c-nav .pf-v6-c-menu.pf-m-drilldown--pf-v6-c-menu__list-item--hover--BackgroundColor
(In light theme) #ffffff
.pf-v6-c-nav__nav--pf-v6-c-nav__item--RowGap--row-offset
calc(0.5rem / 2 * -1)
.pf-v6-c-nav__nav--pf-v6-c-nav__link--clickable-inset--Block
calc(0.5rem / 2 * -1)
.pf-v6-c-nav__nav--pf-v6-c-nav__button--RowGap--row-offset
calc(0.5rem * -1)
.pf-v6-c-nav__subnav--pf-v6-c-nav__list--RowGap
3px
.pf-v6-c-nav__link.pf-m-current--pf-v6-c-nav__link-icon--Color
(In light theme) #1f1f1f
.pf-v6-c-nav__item:where(.pf-m-flyout) .pf-v6-c-nav__toggle-icon--pf-v6-c-nav__item--m-expanded__toggle-icon--Rotate
0
.pf-v6-c-nav__scroll-button:first-of-type .pf-v6-c-button--pf-v6-c-button--BorderStartStartRadius
999px
.pf-v6-c-nav__scroll-button:first-of-type .pf-v6-c-button--pf-v6-c-button--BorderEndStartRadius
999px
.pf-v6-c-nav__scroll-button:last-of-type .pf-v6-c-button--pf-v6-c-button--BorderStartEndRadius
999px
.pf-v6-c-nav__scroll-button:last-of-type .pf-v6-c-button--pf-v6-c-button--BorderEndEndRadius
999px
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--BackgroundColor
(In light theme) #f2f2f2
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--m-horizontal__list--PaddingBlockStart
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--m-horizontal__list--PaddingBlockEnd
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--m-horizontal__list--PaddingInlineStart
1rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--m-horizontal__list--PaddingInlineEnd
1rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--m-horizontal--m-scrollable__list--PaddingInlineStart
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav--m-horizontal--m-scrollable__list--PaddingInlineEnd
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav__link--PaddingBlockStart
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-subnav--pf-v6-c-nav__link--PaddingBlockEnd
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-scrollable--pf-v6-c-nav--m-horizontal__list--PaddingInlineStart
0.25rem
.pf-v6-c-nav:where(.pf-m-horizontal).pf-m-scrollable--pf-v6-c-nav--m-horizontal__list--PaddingInlineEnd
0.25rem