NavItem

OverviewExamplesPropertiesSlotsMethodsEventsCSS PropertiesDependenciesUsageIntegration

Navigation item populates sidebar navigation with links. Every item should be placed inside a navigation group.

Loading...

Properties

PropertyAttribute Description TypeDefault
activeactiveUsed for indicating the current page. This gives a prominent background to the nav item, and marks the item as the current page for assistive technology.booleanfalse
iconiconThe name of an icon from Nordicons to display for the nav item.string | undefined
hrefhrefThe url the nav item should link to. Note: this is not used if you have nested navigation using the "subnav" slot.string | undefined
badgebadgeAllows you to add a notification badge with a number next to the nav item.string | undefined
openopenWhen the nav items contains a subnav, controls whether the section is expanded or not. Note: this is only used if you have nested navigation using the "subnav" slot.booleanfalse

Slots

Slot name Description
Default slotThe default slot used for the nav item's text.
iconSlot for a custom leading icon element. Use when the `icon` attribute isn't enough — for example, an icon wrapped in a styled badge or circular frame. When set, it takes priority over the `icon` attribute and is shown in both the expanded nav and the collapsed rail.
endTrailing content rendered after the label inside the item's flex row. The slotted element flows naturally — it claims its real width and the label flex-shrinks to make room. Use for a custom badge, count pill, action icon, etc. when the `badge` attribute's plain text isn't enough.
subnavUsed for nesting navigation. When used the nav-item becomes a button to collapse the subnav, rather than a link.
rail-tooltipFull content of the rail-mode tooltip. When provided, it replaces the default label projection — write the tooltip's content directly (label + count + keyboard shortcut etc., bound to whatever reactive state you like). When absent, the tooltip falls back to the item's default-slot label. Only rendered in rail mode.

Methods

Method nameParameters Description
focus(options?: FocusOptions) => voidoptions: An object which controls aspects of the focusing process.Programmatically move focus to the component.
blur() => voidN/AProgrammatically remove focus from the component.
click() => voidN/AProgrammatically simulates a click on the component.
EventDetail TypeDescription
toggleNordEventDispatched whenever a nav item's state changes between open and closed.
activateNordEventDispatched whenever a nav item has been marked as active

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-nav-item-colorText color in the default state.var(--n-color-text-weak)
--n-nav-item-backgroundBackground color in the default state.transparent
--n-nav-item-border-radiusBorder radius of the item and its active-parent overlay.var(--n-border-radius-s)
--n-nav-item-padding-blockBlock-axis (top/bottom) padding.var(--n-space-s)
--n-nav-item-padding-inlineInline-axis (start/end) padding.var(--n-space-s)
--n-nav-item-line-heightLine height of the item's text.var(--n-line-height-tight)
--n-nav-item-icon-gapInline gap between the leading icon (the icon attribute or icon slot) and the item's text.calc(var(--n-space-s) * 1.4)
--n-nav-item-color-hoverText color on hover.var(--n-color-text)
--n-nav-item-background-hoverBackground color on hover.var(--n-color-nav-hover)
--n-nav-item-color-activeText color when the item is active.var(--n-color-text-on-accent)
--n-nav-item-background-activeBackground color when the item is active.var(--n-color-accent)
--n-nav-item-color-expandedText color when the item is an active parent (its subnav is expanded).var(--n-color-text-weak)
--n-nav-item-background-expandedBackground color of the overlay drawn behind an active-parent item.var(--n-color-accent)
--n-nav-item-expanded-overlay-opacityOpacity of the active-parent overlay. Set to 1 for a solid background.0.12
--n-nav-item-expanded-overlay-filterFilter applied to the active-parent overlay. Set to none to disable.brightness(150%)
--n-rail-flyout-backgroundBackground colour of the rail-mode subnav flyout container.var(--n-color-surface)
--n-rail-flyout-box-shadowBox-shadow of the rail-mode subnav flyout container.var(--n-box-shadow-popout)
--n-rail-flyout-min-inline-sizeMinimum inline size (width in LTR) of the rail-mode subnav flyout body.220px
--n-rail-flyout-paddingPadding of the rail-mode subnav flyout body.var(--n-space-s)
--n-rail-flyout-offset-inlineExtra inline-axis offset applied to the rail flyout (positive values push it away from the rail in LTR; mirrored in RTL).0
--n-rail-flyout-offset-blockExtra block-axis offset applied to the rail flyout (positive values push it downward).0
--n-rail-subnav-indicator-colorColour of the small triangle indicator drawn in the bottom-inline-end corner of rail items that have a subnav (default + hover state).var(--n-color-border-strong)
--n-rail-subnav-indicator-color-activeColour of the triangle indicator while the item's flyout popout is open.var(--n-color-border-hover)
--n-nav-badge-backgroundBackground colour of the built-in badge attribute pill (.n-nav-badge).var(--n-color-status-notification)
--n-nav-badge-colorText colour of the built-in badge attribute pill.#fff
--n-nav-badge-font-sizeFont size of the built-in badge attribute pill.var(--n-font-size-xs)
--n-nav-badge-font-weightFont weight of the built-in badge attribute pill.var(--n-font-weight)
--n-nav-badge-line-heightLine height of the built-in badge attribute pill. Combined with --n-nav-badge-padding-block this controls the pill's effective block size.1
--n-nav-badge-padding-blockBlock-axis padding of the built-in badge attribute pill.var(--n-space-xs)
--n-nav-badge-padding-inlineInline-axis padding of the built-in badge attribute pill.calc(var(--n-space-s) / 2)
--n-nav-badge-border-radiusBorder radius of the built-in badge attribute pill.var(--n-border-radius-pill)
--n-nav-badge-min-inline-sizeMinimum inline size (width in LTR) of the built-in badge attribute pill — sets a visual floor for single-digit counts.20px
--n-nav-badge-margin-inline-startInline-start margin separating the badge from the preceding label inside the nav-item's flex row.var(--n-space-xs)
--n-rail-badge-sizeDiameter of the rail-mode dot the badge collapses into when the layout is in collapse-mode="rail" and not nav-open.5px

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Group navigation items into navigation groups based on related categories.
  • Use group headings to clarify the category of a section.
  • Use icons for all top level navigation items.

Don’t

  • Don’t use navigation item outside of navigation group and navigation components.

Content guidelines

When writing navigation item labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):

My tasks
My Tasks

Avoid unnecessary words and articles in item labels, such as “the”, “an” or “a”:

Change theme
Change the theme

Avoid ending item labels in punctuation:

Switch user
Switch user.

Use as few words as possible to describe each item label:

Payments
Payments in your clinic

Avoid all caps for item labels and group titles:

Dashboard
DASHBOARD

Integration

For integration guidelines, please see Web Components documentation .

Was this page helpful?

Yes No

We use this feedback to improve our documentation.