Skip to main content

V1SubNavigationMenu

Used to display a navigation menu with links and dropdowns.

Submit feedback
github
V1 components are not compatible with the flattenTokens hook or the DefaultPropsProvider, nor can they be themed using component-level design tokens.
A future redesign will deliver V2 versions of these components and make them compatible with these features.
import { V1SubNavigationMenu } from '@uhg-abyss/web/ui/SubNavigationMenu';

Usage

Utilize V1SubNavigationMenu to create a navigation menu on the side of your web page.

Scroll

When the Menu has overflow it will begin to scroll.

Title

Use the title prop to pass in a title for the Menu.

SubText

Use the subText prop to pass in a description for the Menu.

HeadingLevel

Use the headingLevel prop to pass in a specified headingLevel for the title. The default is h3.

When using V1SubNavigationMenu

In <main> content (such as a "left nav"):

  • `it is likely appropriate for titleTag to be a page heading
  • Set titleTag to "h2" to "h6" to correctly nest in the heading hierarchy (to create <h2> to <h6>)

As part of a larger navigation element (such as NavMenu):

  • it is appropriate for titleTag to be an element that correctly nests in the parent
  • Set titleTag to "div" to create <div> or other appropriate child element

Width

Use the width prop to set the width of the menu. Defaults to 320px.

Height

Use the height prop to set the height of the menu. Defaults to 100%.

Use the navItems prop to specify what is displayed in the V1SubNavigationMenu. The prop requires an array of objects that have the form:

navItems: [
{
title: 'string',
href: 'string',
isDisabled: 'boolean',
before: 'node',
after: 'node',
onClick: 'func',
openNewWindow: 'boolean',
subItems: 'object[]',
isOpenByDefault: 'boolean',
removeCollapse: 'boolean',
},
];

Set active

V1SubNavigationMenu will inherently determine if the current location path matches a nav-item path and apply the default active state styles.

If you'd like to override this default behavior and manually handle setting of the active state, you can use the setActive prop. setActive is a function that's called as part of a loop through all nav-menu items on render and provides a single argument with each nav-menu item. Return true to the item you'd like the default active state styling to be applied. Custom styling can be accomplished by targeting the abyss-sub-navigation-menu-link-active class.

Multi level dropdowns

V1SubNavigationMenu supports up to three levels of dropdown items. To supply an additional level, pass in an array of sub-item objects to the subItems property on the sub-item dropdown you'd like it to be applied.

Controlled expansion state

Use the expandedItems, and onToggleExpansion props to control open/closed state of dropdowns externally. Both of these props must be provided to enable controlled expansion.

Note:: isOpenByDefault is no longer applicable when using controlled expansion.

{
const [expandedItems, setExpandedItems] = React.useState({
'0': false,
'0-0': false,
});
const toggleExpansion = (path: string, nextOpen: boolean) => {
setExpandedItems((prev) => ({
...prev,
[path]: nextOpen,
}));
};
//...
return (
<V1SubNavigationMenu
expandedItems={expandedItems}
onToggleExpansion={toggleExpansion}
//...
/>
);
}

Default selection example

Closing nested dropdowns when closing parent

Programmatic control example

Clickable header title

To render the V1SubNavigationMenu header title as a link, pass in an href to the titleHref prop. To render as a button, pass in a callback function to titleOnClick.

titleHref

titleOnClick

Pass in the prop variant and set the value to sideBarMenu in order to turn your V1SubNavigationMenu into a side bar menu that lists out all available links.

Position

Set the position prop to left when aligning the sideBarMenu variant to the right side of the screen. This will move the active indicator to the left side and update the menu alignment. position is set to right by default

V1SubNavigationMenu Props

Prop NameTypeDefaultDescription
headingLevelh1 | h2 | h3 | h4 | h5 | h6h3changes the heading level of the title. defaults to h3
heightstring | number100%changes the height of the menu. Defaults to 100%
navItemsobject[][]Array of menu items. { title: string, isDisabled: boolean, href: string, before: node, after: node, isOpenByDefault: boolean, subItems: object[], openNewWindow: boolean, onClick: function, isActive: boolean, removeCollapse: boolean}
onClickfunction-Callback fired when the dropdown is clicked
positionleft | rightrightPositions nav on the left or right side
setActivefunction-Callback function to manually set active state for nav-menu links
subTextstring-Description of the V1SubNavigationMenu
titlestring-Title of the SubNavigrationMenu
titleHrefstring-Adds a link to V1SubNavigationMenu header title
titleOnClickfunction-Callback function fired when V1SubNavigationMenu header title is clicked
variantdefault | sideBarMenudefaultchanges V1SubNavigationMenu into a sideBarMenu
width string | number320pxchanges the width of the menu

V1SubNavigationMenu Classes

Class NameDescription
.abyss-sub-navigation-dropdown-buttonDropdown button
.abyss-sub-navigation-dropdown-button-chevronButton Chevron
.abyss-sub-navigation-dropdown-containerDropdown container
.abyss-sub-navigation-dropdown-list-containerDropdown links container
.abyss-sub-navigation-dropdown-titleDropdown title/link
.abyss-sub-navigation-dropdown-wrapperDropdown wrapping title and button
.abyss-sub-navigation-header-containerHeader container
.abyss-sub-navigation-header-textHeader subText
.abyss-sub-navigation-header-titleHeader title
.abyss-sub-navigation-menu-itemMenu List item
.abyss-sub-navigation-menu-itemsMenu items unordered list
.abyss-sub-navigation-menu-linkMenu Link
.abyss-sub-navigation-menu-link-activeMenu Link Active
.abyss-sub-navigation-menu-rootroot element

For icon accessibility, please refer to the IconSymbol docs.

V1SubNavigationMenu is a WAI-ARIA Tree View pattern that follows the Navigation Treeview Example and "Disclosure" approach described in the notes. This is so default operation is more predictable using tabs for website navigation. Arrow key implementation is more appropriate for a web application.

Keyboard Interactions

KeyDescription
TabTraverse the SubNavMenu
EnterSelect a SubNavMenu item. When hitting Enter on a dropdown, it will open/close the dropdown
Down ArrowMoves focus to the next node that is focusable without opening or closing a node
Up ArrowMoves focus to the previous node that is focusable without opening or closing a node
HomeMoves focus to the first node in the tree without opening or closing a node
EndMoves focus to the last node in the tree that is focusable without opening a node
Right ArrowFocus is on a closed dropdown, opens the dropdown; focus does not move
Left ArrowFocus is on an open dropdown, closes the dropdown
A-Z or a-zMoves focus to the next menu item with a label that starts with the typed character if such an menu item exists. Otherwise, focus does not move
Table of Contents