Skip to main content

V1SubNavigationMenu

Used to display a navigation menu with links and dropdowns.

github
View source code
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​

Name
Type
DefaultA11yDescription
className
string | undefined
CSS class name to apply to each element within the component
css
CSSProperties | Partial<Record<"abyss-sub-navigation-menu-root" | "abyss-sub-navigation-header-container" | "abyss-sub-navigation-header-title" | "abyss-sub-navigation-header-text" | ... 9 more ... | "abyss-sub-navigation-dropdown-list-container", CSSProperties>> | undefined
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation
See CSS Prop Styling for more information
data-testid
string | undefined
Suffix used to create a unique ID used for automated testing
See Component Testing for more information
expandedItems
Record<string, boolean> | undefined
Controlled expansion state for all dropdowns.
headingLevel
"h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined
'h3'
The semantic heading level for the menu's title, so it fits correctly into the page's heading structure for screen readers.
height
string | number | undefined
'100%'
The height of the SubNavigationMenu component.
hiddenFrom
Breakpoint | undefined
When defined, the component is hidden once the screen width reaches the specified breakpoint.
navItems
SubNavigationMenuNavItem[] | undefined
The navigation items for the SubNavigationMenu component.
onToggleExpansion
((path: string, nextOpen: boolean) => void) | undefined
Callback fired when a dropdown's expansion state changes.
position
"left" | "right" | undefined
'right'
The position of the SubNavigationMenu component.
setActive
((menuItem: SubNavigationMenuNavItem) => boolean) | undefined
The callback function to set the active state of a menu item.
slotProps
Partial<Record<string, SlotPropsValue<string>>> | undefined
Props to pass to individual internal slots of the component, keyed by the slot name
(e.g. 'button-root'). Supports className, css, style, aria-*, data-*,
data-testid, and nested slotProps for child Abyss components.
See slotProps for more information
subText
string | undefined
The subtext for the SubNavigationMenu component.
title
string | undefined
The title for the SubNavigationMenu component.
titleHref
string | undefined
The href for the title of the SubNavigationMenu component.
Renders title as a link.
titleOnClick
MouseEventHandler<HTMLElement>
The onClick event handler for the title of the SubNavigationMenu component.
Renders title as a button.
titleRouterComponent
ComponentType<any> | undefined
Custom router component to use for client-side navigation on title link
(e.g., Next.js Link, Gatsby Link, etc.)
variant
"default" | "sideBarMenu" | undefined
'default'
The variant of the SubNavigationMenu component.
- 'default': Default variant.
- 'sideBarMenu': Converts SubNavigationMenu into a side bar menu
visibleFrom
Breakpoint | undefined
When defined, the component is hidden until the screen width reaches the specified breakpoint.
width
string | number | undefined
'320px'
The width of the SubNavigationMenu component.

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-rootSubNavigationMenu root element

For icon accessibility, please refer to the IconSymbol docs.

V1SubNavigationMenu is a WAI-ARIA Tree View patternopens in a new window that follows the Navigation Treeview Exampleopens in a new window 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