Use Anchor Bar...
- To display a horizontal sub-navigation, allowing you to link to a section of the current page.
Don't use Anchor Bar...
- To link outside of the page.
List Item Description
Use the optional AnchorBarListItemDescription
component to disable a description / sub-title for an anchor element. Use it as a child of the anchor element.
If using AnchorBarListItemDescription
, we recommend using a description on all listed items to ensure consistent horizontal alignment of item and description copy.
Sticky
Use sticky
to make the Anchor Bar stick to the top of the viewport as the user scrolls past it. It also enables the logic to detect the currently active anchor item. To associate a page element with an anchor, the href of the anchor must match the id of the element, prefixed with #
. This creates a native html in-page anchor link.
When links are associated with elements elsewhere on the page, the Anchor Bar will track when those elements scroll into view to denote the currently active anchor link.
To mark an anchor as active (with the underline styling) set aria-active="true"
on the anchor (or Link) component.
onActiveAnchorChanged
will be called when a destination element scrolls into the viewport.
The preview has been updated.
Background color
Use bgc
or backgroundColor
to set the background color of the Anchor Bar. The same background color will be used for both the default and sticky versions.
Use darkMode
to use dark mode settings on darker colors.