NavItem
Navigation item populates sidebar navigation with links. Every item should be placed inside a navigation group.
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
active | active | Used 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. | boolean | false |
icon | icon | The name of an icon from Nordicons to display for the nav item. | string | undefined | — |
href | href | The url the nav item should link to. Note: this is not used if you have nested navigation using the "subnav" slot. | string | undefined | — |
badge | badge | Allows you to add a notification badge with a number next to the nav item. | string | undefined | — |
open | open | When 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. | boolean | false |
Slots
| Slot name | Description |
|---|---|
Default slot | The default slot used for the nav item's text. |
subnav | Used for nesting navigation. When used the nav-item becomes a button to collapse the subnav, rather than a link. |
Methods
| Method name | Parameters | Description |
|---|---|---|
focus(options?: FocusOptions) => void | options: An object which controls aspects of the focusing process. | Programmatically move focus to the component. |
blur() => void | N/A | Programmatically remove focus from the component. |
click() => void | N/A | Programmatically simulates a click on the component. |
| Event | Detail Type | Description |
|---|---|---|
toggle | NordEvent | Dispatched whenever a nav item's state changes between open and closed. |
activate | NordEvent | Dispatched 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.
| Property | Description | Default |
|---|---|---|
--n-nav-item-color | Text color in the default state. | var(--n-color-text-weak) |
--n-nav-item-background | Background color in the default state. | transparent |
--n-nav-item-border-radius | Border radius of the item and its active-parent overlay. | var(--n-border-radius-s) |
--n-nav-item-padding-block | Block-axis (top/bottom) padding. | var(--n-space-s) |
--n-nav-item-padding-inline | Inline-axis (start/end) padding. | var(--n-space-s) |
--n-nav-item-line-height | Line height of the item's text. | var(--n-line-height-tight) |
--n-nav-item-color-hover | Text color on hover. | var(--n-color-text) |
--n-nav-item-background-hover | Background color on hover. | var(--n-color-nav-hover) |
--n-nav-item-color-active | Text color when the item is active. | var(--n-color-text-on-accent) |
--n-nav-item-background-active | Background color when the item is active. | var(--n-color-accent) |
--n-nav-item-color-expanded | Text color when the item is an active parent (its subnav is expanded). | var(--n-color-text-weak) |
--n-nav-item-background-expanded | Background color of the overlay drawn behind an active-parent item. | var(--n-color-accent) |
--n-nav-item-expanded-overlay-opacity | Opacity of the active-parent overlay. Set to 1 for a solid background. | 0.12 |
--n-nav-item-expanded-overlay-filter | Filter applied to the active-parent overlay. Set to none to disable. | brightness(150%) |
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):
Avoid unnecessary words and articles in item labels, such as “the”, “an” or “a”:
Avoid ending item labels in punctuation:
Use as few words as possible to describe each item label:
Avoid all caps for item labels and group titles:
Integration
For integration guidelines, please see Web Components documentation .