Componentsv2.189.0
Iconsv1.19.0
MCPv0.8.61
Tokensv0.34.3

A component to display a navigation button in a sidebar.

Importing

The component can be imported via:

import { NavItem } from '@customerio/pluma-components/react';

For expandable nav items:

import {
	NavItemExpandable,
	NavItemExpandableTrigger,
	NavItemExpandableContent,
} from '@customerio/pluma-components/react';

For dropdown nav items:

import {
	NavItemDropdown,
	NavItemDropdownTrigger,
	NavItemDropdownContent,
	DropdownMenuGroup,
	DropdownMenuItem,
} from '@customerio/pluma-components/react';

Usage

The NavItem component accepts a href prop, just like other components that extend from PlainLink.

Additionally, an icon can be provided to render an icon next to the label.

Loading editor

Selected

Use the isSelected prop to indicate the currently active nav item - for example, to indicate the currently active page.

Loading editor

Custom elements

Use elementBefore and elementAfter to render custom content in the leading and trailing parts of the nav item. elementBefore renders in the leading slot, after the icon if one is present; elementAfter renders in the trailing slot, before the expand arrow when withArrow is set. Both compose with the built-in icon/arrow rather than replacing them.

In React, both are node props. In Ember, they can be passed as a component or, more commonly, via the :elementBefore and :elementAfter named blocks (the label is then provided via the :default block).

Loading editor

Inline visibility

Use isVisibleWhenSelected and isVisibleWhenDeselected when a nav item should remain available in navigation data but only appear inline for specific selection states. This is useful for items that live in another menu while deselected, but should animate into their original position when they become selected.

isSelected and hasSelectedChild both count as the selected state for this visibility behavior.

Loading editor

Collapsed

Use the isCollapsed prop to hide the label and only show the icon. This can be used when collapsing a navigation sidebar for a condensed view.

Loading editor

Expandable content

NavItemExpandable, NavItemExpandableTrigger, and NavItemExpandableContent can be used to create a group of nav items that can be expanded and collapsed.

NavItemExpandable is a wrapper component that provides the context for the nested items. It doesn't render anything itself.

NavItemExpandableTrigger is a component that renders a NavItem which functions as an expand/collapse toggle button for the section.

NavItemExpandableContent is the container for the nested items. When the section's state is expanded, it will render the nested elements.

Loading editor

Default open

Use the defaultIsOpen prop to have the expandable section open by default.

Loading editor

NavItemDropdown, NavItemDropdownTrigger, and NavItemDropdownContent can be used to create a group of nav items where a subset is shown inline (animated in/out based on selection), and the rest are accessible via a dropdown menu triggered by the trigger item.

NavItemDropdown wraps the entire group.

NavItemDropdownContent contains the nav items that animate in when selected and collapse when deselected.

NavItemDropdownTrigger renders a nav item that opens a dropdown menu containing all the items from NavItemDropdownContent.

Use menuBefore and menuAfter to add content that should only appear in the dropdown menu. In Ember, use <:menuBefore> and <:menuAfter> named blocks. This is useful for actions that relate to the navigation itself, but should not render as animated inline nav items.

Loading editor

Additional dropdown content can be rendered before or after the nav items without also rendering it inline in the side navigation.

Loading editor

API

The id of the element controlled by the arrow button, if the arrow is independently interactive.

Whether the element controlled by the arrow button is expanded, if the arrow is independently interactive.

The accessible label for the arrow button, if the arrow is independently interactive.

Which direction the arrow should point, if withArrow is true.

Custom content to render in the trailing (after) slot of the nav item, alongside the expand arrow when withArrow is set. In React this is a node; in Ember it can be passed as a component or provided via the :elementAfter named block.

Custom content to render in the leading (before) slot of the nav item, in place of the icon. In React this is a node; in Ember it can be passed as a component or provided via the :elementBefore named block.

If this item is the trigger for an expandable section, this indicates whether any of the child items are selected.

The URL passed into the link component (or a tag)

The name of an icon (from Pluma Icons) to render in the nav item

Whether the nav item should render in the "collapsed" state, which hides the text and only shows the icon.

Whether the link should be disabled (this prevents click handlers from firing)

When this flag is true, an a tag will be used instead of the provider's linkComponent, even if it exists. Additionally, target="_blank" rel="noopener noreferrer" will be added automatically

Whether this nav item is nested within another nav item.

Whether this nav item is currently active/selected, which changes the item's appearance.

Whether the nav item should be visible in the inline navigation when it is not selected.

Whether the nav item should be visible in the inline navigation when it is selected.

If provided with href and withArrow, the arrow will render as a separate button and call this function when clicked.

If provided, the component will render as a button and call this function when clicked.

This is passed into the provider's linkComponent. It can be used by the link component implementation to handle replaceState instead of pushState

Whether an arrow icon should be rendered on the right side of the nav item, indicating that this is a parent item that can be expanded to show child items.

This allows turning off the automatic addition of target="_blank" rel="noopener noreferrer". This can be used for links to other protocols like mailto:

Whether the expandable section should be open by default.

The id of the element controlled by the arrow button, if the arrow is independently interactive.

Whether the element controlled by the arrow button is expanded, if the arrow is independently interactive.

The accessible label for the arrow button, if the arrow is independently interactive.

Which direction the arrow should point, if withArrow is true.

Custom content to render in the trailing (after) slot of the nav item, alongside the expand arrow when withArrow is set. In React this is a node; in Ember it can be passed as a component or provided via the :elementAfter named block.

Custom content to render in the leading (before) slot of the nav item, in place of the icon. In React this is a node; in Ember it can be passed as a component or provided via the :elementBefore named block.

If this item is the trigger for an expandable section, this indicates whether any of the child items are selected.

The URL passed into the link component (or a tag)

The name of an icon (from Pluma Icons) to render in the nav item

Whether the nav item should render in the "collapsed" state, which hides the text and only shows the icon.

Whether the link should be disabled (this prevents click handlers from firing)

When this flag is true, an a tag will be used instead of the provider's linkComponent, even if it exists. Additionally, target="_blank" rel="noopener noreferrer" will be added automatically

Whether this nav item is nested within another nav item.

Whether this nav item is currently active/selected, which changes the item's appearance.

Whether the nav item should be visible in the inline navigation when it is not selected.

Whether the nav item should be visible in the inline navigation when it is selected.

If provided with href and withArrow, the arrow will render as a separate button and call this function when clicked.

If provided, the component will render as a button and call this function when clicked.

This is passed into the provider's linkComponent. It can be used by the link component implementation to handle replaceState instead of pushState

Whether an arrow icon should be rendered on the right side of the nav item, indicating that this is a parent item that can be expanded to show child items.

This allows turning off the automatic addition of target="_blank" rel="noopener noreferrer". This can be used for links to other protocols like mailto:

Content to render after the nav items in the dropdown menu only.

Content to render before the nav items in the dropdown menu only.