VerticalNavigation
Navigation enables users to move through an app to complete tasks.
It is recommended to use vertical navigation when your application requires global navigation that is displayed on the left. While vertical navigation menus generally consume more space than their horizontal counterparts, they have become more popular as desktop monitors move to wide-screen formats.
Although both the hierarchically organized data and the visual style resemble a treeview-like structure, the Treeview Design Pattern isn't necessarily the most appropriate.
The tree role provides complex functionality that is not needed for typical site navigation, and changes the most common keyboard navigation using TAB.
The Disclosure Design Pattern is more suited for typical site navigation, with expandable groups of links. However it can be tedious to TAB through all navigation items to reach the actions panel.
Both modes are available via the mode
property and each app should choose the most appropriate.
Usage
The sample below illustrates a common use of the HvVerticalNavigation
component. The HvVerticalNavigationTree
component is used to render the navigation tree. The HvVerticalNavigationActions
component is used to render the actions at the bottom of the navigation.
Tree view
Usage of the Treeview Design Pattern to build a navigation tree for a set of hierarchically organized web pages. Instead of TAB, use the arrow keys to navigate through items. Enter performs its default action (i.e. open/close parent nodes, select otherwise).
Set the mode
prop to treeview
to enable the tree view and set collpasible
to true
to enable collpasing non-leaf items.
Collapsible
If you want the navigation to be collapsible, you can use the HvVerticalNavigationHeader
component to add a collapse button to the navigation.
You’ll have to manage the open state of the navigation yourself and pass it to the open
prop of the HvVerticalNavigation
component. The
collapse button will show if you pass a handler function to the onCollapseButtonClick
prop.
You can also use the useIcons
prop to show icons in the navigation when collapsed, if an icon is not provided one will be generated based on the first letter of the label.
Slider
If you set the slider
prop to true
, the navigation will be displayed as a slider instead of a tree. When the user selects an item that contains
children, the content of the navigation will be replaced with the children of the selected item.
You can use this functionality to display the navigation in regular tree view mode and switch to slider mode when the screen size is lower that a certain threshold.