Subnavigation
Importing
Add rh-subnav to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-subnav/rh-subnav.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Lightdom CSS
This element requires you to load "Lightdom CSS" stylesheets for styling deeply slotted elements.
Note
Replace /path/to/ with path to the CSS file, whether local or CDN.
<link rel="stylesheet" href="/path/to/rh-subnav/rh-subnav-lightdom.css">
Usage
<rh-subnav>
<a href="#">Users</a>
<a href="#">Containers</a>
<a href="#">Databases</a>
<a href="#" aria-current="page">Servers</a>
<a href="#">System</a>
<a href="#">Network</a>
<a href="#">Cloud</a>
</rh-subnav>
<link rel="stylesheet" href="../rh-subnav-lightdom.css">
<script type="module">
import '@rhds/elements/rh-subnav/rh-subnav.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-subnav
A subnavigation provides a horizontal list of links for navigating
related pages. Authors should slot <rh-navigation-link> elements
as children; authors should avoid slotting bare <a> elements, which
are deprecated. Each link must have visible text content for
accessibility. When more than one subnav appears on a page, authors
should set accessible-label so screen readers can distinguish them.
Overflow scroll buttons appear when links exceed the available space. All links are keyboard accessible via Tab and Enter.
Slots
1
| Slot Name | Summary | Description |
|---|---|---|
Sub navigation links |
Expects a collection of |
Attributes
4
1
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
|
|
accessibleLabel |
Customize the default |
|
|
|
|
labelScrollLeft |
Label for the scroll back button |
|
|
|
|
labelScrollRight |
Label for the scroll forward button |
|
|
Deprecated Attributes
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
color-palette |
colorPalette |
Sets color palette, which affects the element's styles as well as descendants' color theme. Overrides parent color context. Your theme will influence these colors so check there first if you are seeing inconsistencies. See CSS Custom Properties for default values |
|
|
Methods
0
None
Events
0
None
CSS Shadow Parts
2
| Part Name | Summary | Description |
|---|---|---|
|
|
The nav container wrapping the link list |
|
|
|
The scrollable link list container |
CSS Custom Properties
0
None
Design Tokens
14
| Token | Description | Copy |
|---|---|---|
--rh-color-surface
|
Theme surface color token for subnav background |
|
--rh-color-accent-brand
|
Brand accent design token for current page |
|
--rh-border-width-md
|
Focus outline width 2px border width: Example: Alert |
|
--rh-color-border-interactive
|
Focus outline color |
|
--rh-space-xs
|
Navigation link gap between text and icon 4px spacer |
|
--rh-space-2xl
|
Link inline padding Navigation link inline padding 32px spacer |
|
--rh-font-size-body-text-md
|
Navigation link font size 16px font size |
|
--rh-color-brand-red
|
Current page border block end color |
|
--rh-space-lg
|
Link block padding Navigation link block padding Scroll button inline padding 16px spacer |
|
--rh-color-text-secondary
|
Theme secondary text token for inactive links Scroll buttons text color |
|
--rh-color-text-primary
|
Theme primary text token for active links Theme primary text token for visited links Navigation link text color Navigation link hover text color Scroll button hover text color |
|
--rh-border-width-lg
|
Link state indicator border block end width Navigation link state indicator border block Scroll button state border block end width 3px border width: Example: Expanded Accordion panel |
|
--rh-border-width-sm
|
Previous button border inline end width Next button border inline start width Scroll button border block end width 1px border width; Example: Secondary CTA or Button |
|
--rh-color-border-subtle
|
Subtle border on hover and focus Navigation link hover subtle border block end color Disabled scroll buttons text color Scroll button hover border block end color Previous button border inline end color Next button border inline start color Scroll button border block end color |
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.