import {UnderlineNav} from '@primer/react/drafts'
<UnderlineNav aria-label="Repository"><UnderlineNav.Item selected>Item 1</UnderlineNav.Item><UnderlineNav.Item>Item 2</UnderlineNav.Item><UnderlineNav.Item>Item 3</UnderlineNav.Item></UnderlineNav>
<UnderlineNav aria-label="Repository"><UnderlineNav.Item selected icon={CodeIcon}>Code</UnderlineNav.Item><UnderlineNav.Item icon={IssueOpenedIcon} counter={30}>Issues</UnderlineNav.Item><UnderlineNav.Item icon={GitPullRequestIcon} counter={3}>Pull Requests</UnderlineNav.Item><UnderlineNav.Item icon={CommentDiscussionIcon}>Discussions</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon} counter={9}>Actions</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon} counter={7}>Projects</UnderlineNav.Item></UnderlineNav>
When overflow occurs, the component first hides icons if present to optimize for space and show as many items as possible. (Only for fine pointer devices)
<UnderlineNav aria-label="Repository"><UnderlineNav.Item selected icon={CodeIcon}>Code</UnderlineNav.Item><UnderlineNav.Item icon={IssueOpenedIcon} counter={30}>Issues</UnderlineNav.Item><UnderlineNav.Item icon={GitPullRequestIcon} counter={3}>Pull Requests</UnderlineNav.Item><UnderlineNav.Item icon={CommentDiscussionIcon}>Discussions</UnderlineNav.Item><UnderlineNav.Item icon={PlayIcon} counter={9}>Actions</UnderlineNav.Item><UnderlineNav.Item icon={ProjectIcon} counter={7}>Projects</UnderlineNav.Item><UnderlineNav.Item icon={ShieldLockIcon}>Security</UnderlineNav.Item><UnderlineNav.Item icon={GraphIcon}>Insights</UnderlineNav.Item><UnderlineNav.Item icon={GearIcon} counter={1}>Settings</UnderlineNav.Item></UnderlineNav>
More
MenuIf there is still overflow, the component will behave depending on the pointer.
<UnderlineNav aria-label="Repository"><UnderlineNav.Item selected icon={CodeIcon}>Code</UnderlineNav.Item><UnderlineNav.Item icon={IssueOpenedIcon} counter={30}>Issues</UnderlineNav.Item><UnderlineNav.Item icon={GitPullRequestIcon} counter={3}>Pull Requests</UnderlineNav.Item><UnderlineNav.Item icon={CommentDiscussionIcon}>Discussions</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon} counter={9}>Actions</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon} counter={7}>Projects</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon}>Security</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon} counter={14}>Insights</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon} counter={1}>Settings</UnderlineNav.Item><UnderlineNav.Item icon={EyeIcon}>Wiki</UnderlineNav.Item></UnderlineNav>
<UnderlineNav aria-label="Repository" loadingCounters={true}><UnderlineNav.Item counter={4} selected>Item 1</UnderlineNav.Item><UnderlineNav.Item counter={44}>Item 2</UnderlineNav.Item><UnderlineNav.Item>Item 3</UnderlineNav.Item></UnderlineNav>
Name | Type | Default | Description |
---|---|---|---|
aria-label | string | A 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') | |
loadingCounters | boolean | false | Whether all of the counters are in loading state |
afterSelect | (event) => void | The handler that gets called when a nav link child is selected | |
sx | SystemStyleObject | Style overrides to apply to the component. See also overriding styles. |
Name | Type | Default | Description |
---|---|---|---|
icon | Component | The leading icon comes before item label | |
selected | boolean | Whether the link is selected | |
onSelect | (event) => void | The handler that gets called when a nav link is selected | |
as | string | Component | a | What kind of component needs to be rendered |
sx | SystemStyleObject | Style overrides to apply to the component. See also overriding styles. |