Primer

Anchor nav

Use the anchor nav component for prompt navigation to different sections of a page.
import {AnchorNav} from '@primer/react-brand'

Examples

AnchorNav is designed to fix to the top of the viewport, and requires markup outside of the scope of the component to behave correctly.

Please refer to our Storybook examples to see the component in a full-screen context as originally intended.

Basic

Secondary action

AnchorNav can also feature secondary actions. When two actions are present, the first will be presented as the primary variant.

AnchorNav implementations with fewer than 5 links, will automatically align links to the start.

Component props

AnchorNav Required

NameTypeDefaultDescription
children'AnchorNav.Link'
'AnchorNav.Action'
'ReactNode'
,
Valid child nodes
classNamestringSets a custom class
enableDefaultBgColorbooleanfalseEnable the idle state background color, which is transparent by default
hideUntilStickybooleanfalseWhen true, the anchor nav will hide until it is sticky.
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node

AnchorNav.Link are anchor links that feature in the menubar

NameTypeDefaultDescription
childrenstringRequired. Label text
classNamestringApplies a custom class
hrefstringRequired. Local identifier for the anchored element
idstringSets a custom id
isActivebooleanfalseManually indicate that the link is active
refReact.RefObjectForward a Ref to the underlying DOM node

Additional props can be passed to the <a> element. See MDN for a list of props accepted by the <anchor> element.

AnchorNav.Action

AnchorNav.Action is the primary call to action for the AnchorNav

NameTypeDefaultDescription
childrenstringRequired. Label text
classNamestringApplies a custom class
hrefstringRequired. Local identifier for the anchored element
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node

Additional props can be passed to the <a> element. Refer to Button for more details or MDN for a list of props accepted by the <anchor> element.

AnchorNav.SecondaryAction

AnchorNav.SecondaryAction is an alternative call to action available for the AnchorNav

NameTypeDefaultDescription
childrenstringRequired. Label text
classNamestringApplies a custom class
hrefstringRequired. Local identifier for the anchored element
idstringSets a custom id
refReact.RefObjectForward a Ref to the underlying DOM node

Additional props can be passed to the <a> element. Refer to Button for more details or MDN for a list of props accepted by the <anchor> element.