Navigation

A navigation component organizes and communicates an application's structure and content in a central location, making it easy to find information and accomplish tasks.

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