Navigation

The navigation component is used to display the primary navigation in the sidebar of the frame of an application. Navigation includes a list of links that merchants use to move between sections of the application.

Deprecated

This component is no longer supported. Please use the App Bridge Navigation Menu API instead.

Navigation component examples

Use to present a navigation menu in the frame.

import {Frame, Navigation} from '@shopify/polaris';
import {HomeIcon, OrderIcon, ProductIcon} from '@shopify/polaris-icons';
import React from 'react';

function NavigationExample() {
  return (
    <Frame>
      <Navigation location="/">
        <Navigation.Section
          items={[
            {
              url: '#',
              label: 'Home',
              icon: HomeIcon,
            },
            {
              url: '#',
              excludePaths: ['#'],
              label: 'Orders',
              icon: OrderIcon,
              badge: '15',
            },
            {
              url: '#',
              excludePaths: ['#'],
              label: 'Products',
              icon: ProductIcon,
            },
          ]}
        />
      </Navigation>
    </Frame>
  );
}

Required components

The navigation component must be passed to the frame component. The mobile version of the navigation component appears in the top bar component.


Best practices

The navigation component should:

  • Contain primary navigation items that perform an action when clicked. Each action should navigate to a URL or trigger another action like a modal overlay.
  • Only use secondary actions for supplementary actions to the primary actions.
  • Provide a non-primary link or action as a secondary action to a section or an item.
  • Group navigation items into sections based on related categories.
  • Use a section title to clarify the category of a section.
  • Use a major icon for item actions.
  • Use a minor icon for secondary actions.
  • Use the provided navigation section component to group navigation items.
  • Not add additional components, like badge, in navigation items. Example: Don‘t add the New badge.

Content guidelines

Navigation should:

  • Use sentence case for primary and secondary navigation items
Do
  • Online store
Don't
  • Online Store
  • Use as few words as possible to describe each item label
Do
  • Products
Don't
  • Products in your store
  • Use all caps for section labels
Do
  • SALES CHANNELS
Don't
  • Sales channels

A navigation section groups together related navigation items. Navigation sections can be clarified by a heading. Merchants can use a section to easily find navigation items within a specific category.

Section properties

PropTypeDescription
itemsItem[]A collection of navigation items to be rendered inside the section
iconIconProps['source']An icon to be displayed next to the section title
titlestringA string property providing a title for the navigation section
fillbooleanA boolean property indicating whether the section should take up all vertical space available
rollupRollupAn object determining the collapsing behavior of the navigation section
actionActionRenders an icon-only action as a supplementary action next to the section title
separatorbooleanA boolean property indicating whether the section should have a visual separator

The content of the navigation component consists of navigation items. Each item is a link or action a merchant can take.

Item properties

PropTypeDescription
urlstringA location for the navigation item to navigate to when clicked
matchesbooleanA boolean property indicating whether the navigation item should respond to a closely matching location property
exactMatchbooleanA boolean property indicating whether the navigation item should respond to an exactly matching location property
matchPathsstring[]A string property providing a collection of additional paths for the navigation item to respond to
excludePathsstring[]A string property providing an explicit collection of paths the navigation item should not respond to
iconIconProps['source']An icon to be displayed next to the navigation. Please prefer minor icons here. If a major icon has to be used, set the shouldResizeIcon prop to true
badgestring | nullA string property allowing content to be displayed in a badge next to the navigation item
labelstringA string property allowing content to be displayed as link text in the navigation item
disabledbooleanA boolean property indicating whether the navigation item is disabled
newbooleanIndicate whether the navigation item is new by adding an indicator dot to the parent and badge to the item (overwritten by the badge prop)
accessibilityLabelstringA visually hidden label for screen readers to understand the content of a navigation item
selectedbooleanA boolean property indicating whether the navigation item is the currently-selected item
shouldResizeIconbooleanWill allow for major icons to be displayed at the same size as minor icons
subNavigationItemsSubNavigationItem[]A collection of navigation items rendered as nested secondary navigation items
secondaryActionSecondaryActionRenders an icon-only action as a supplementary action next to a navigation item
secondaryActionsSecondaryAction[]Renders one or two icon-only actions as supplementary actions next to a navigation item
onClick()functionA callback function to handle clicking on a navigation item
truncateTextbooleanA boolean property to allow text that exceeds the width of the navigation item to be truncated with ellipsis
displayActionsOnHoverbooleanA boolean to only display secondary actions when being the nabigation item is hovered (Only on desktop)

Properties

PropTypeDescription
urlstringA location for the navigation item to navigate to when clicked
matchesbooleanA boolean property indicating whether the navigation item should respond to a closely matching location property
exactMatchbooleanA boolean property indicating whether the navigation item should respond to an exactly matching location property
matchPathsstring[]A string property providing a collection of additional paths for the navigation item to respond to
excludePathsstring[]A string property providing an explicit collection of paths the navigation item should not respond to
externalbooleanIndicates whether this is an external link. If it is, an external link icon will be shown next to the label
labelstringA string property allowing content to be displayed as link text in the navigation item
disabledbooleanA boolean property indicating whether the navigation item is disabled
newbooleanIndicate whether the navigation item is new by adding an indicator dot to the parent and badge to the item (overwritten by the badge prop)
onClick()functionA callback function to handle clicking on a navigation item

SecondaryAction

Properties

PropTypeDescription
urlstringA location for the navigation item to navigate to when clicked
accessibilityLabelstringA visually hidden label for screen readers to understand the content of a navigation item
iconIconProps['source']An icon to be displayed next to the navigation. Please prefer minor icons here. If a major icon has to be used, set the shouldResizeIcon prop to true
onClick()functionA callback function to handle clicking on a navigation item
tooltipTooltipPropsOptions for displaying a tooltip when you hover over the action button

Rollup allows items in a navigation section to roll up and be revealed when they are of use to the merchant.

Rollup properties

PropTypeDescription
afternumberA number of items after which the navigation section should be collapsed
viewstringA string property providing content for the section view action
hidestringA string property providing content for the section hide action
activePathstringA string property representing the current URL of your application

Action allows a complementary icon-only action to render next to the section title.

Action properties

PropTypeDescription
iconIconProps['source']An icon to be displayed as the content of the action
accessibilityLabelstringA visually hidden label for screen readers to understand the content of the action
onClick()functionA callback function to handle clicking on the action
tooltipTooltipPropsOptions for displaying a tooltip when you hover over the action button

  • To provide the structure for the navigation component, including the left sidebar and the top bar use the frame component.
  • To display the navigation component on small screens, to provide search and a user menu, or to theme the frame component to reflect an application’s brand, use the top bar component.
  • To tell merchants their options once they have made changes to a form on the page use the contextual save bar component.
  • To provide quick, at-a-glance feedback on the outcome of an action, use the toast component.
  • To indicate to merchants that a page is loading or an upload is processing use the loading component.
  • To alternate among related views within the same context, use the tabs component.
  • To embed a single action or link within a larger span of text, use the link component.

    On this page