UnderlineNav
The UnderlineNav is used to display navigation in a horizontal tabbed format.
Page navigation navigation
The UnderlineNav provides navigation links to let users switch between 2 or more related views without leaving their current context.
If you want to use this pattern without any linked items, use the UnderlinePanels component.
React examples
Default
Repository navigation
With counter badges
You may include a counter for relevant counts (e.g., open issues) and load them simultaneously to prevent layout shifts.
When loading multiple counters asynchronously, wait for all the data to be ready before displaying the counters, so you can avoid multiple layout shifts.
Repository with counters navigation
With leading icons
Use consistent, meaningful icons to aid scannability. Either items in the navigation should have a leading icon or none of the items do.
Make sure that icons used are consistent across views, and that they are not repeated for different navigation items across the product.
Repository with leading icons navigation
More code examples
The previous examples are a curated subset of the full capabilities (such as reponsive behavior) of the UnderlineNav component. For more examples, see the UnderilneNav Storybook stories
Props
UnderlineNav
| Name | Default | Description |
|---|---|---|
aria-label | stringA unique name for the rendered nav landmark. It will also be used to label the arrow buttons that control the scroll behaviour on coarse pointer devices. (I.e. 'Scroll aria-label left/right') | |
children Required | UnderlineNav.Item[] | |
loadingCounters | false | booleanWhether the navigation items are in loading state. Component waits for all the counters to finish loading to prevent multiple layout shifts. |
variant | 'inset' | 'inset' | 'flush'
|
sx Deprecated | SystemStyleObject |
UnderlineNav.Item
| Name | Default | Description |
|---|---|---|
aria-current | false | | 'page' | 'step' | 'location' | 'date' | 'time' | true | falseSet |
counter | number | stringThe number to display in the counter label. | |
href | stringThe URL that the item navigates to. | |
icon | ComponentThe leading icon comes before item label | |
onSelect | (event) => voidThe handler that gets called when a nav link is selected. For example, a manual route binding can be done here(I.e. 'navigate(href)' for the react router.) | |
as | "a" | React.ElementType |
sx Deprecated | SystemStyleObject |