Vue playground

Nova v3.38.0

Preview

Vue

Using the sidebar

The parts of the sidebar family, how they fit together and where the sidebar goes in a page.

The sidebar is a family of nine components. NvSidebar is the frame, and the other eight go inside it. This page shows what each part is for and how to place the sidebar in a page. The other chapters cover one topic each:

The parts#

ComponentWhat it is for
NvSidebarThe frame. It holds the mode (type, open), the current route (activePath) and the width.
NvSidebarlogoLogo and product name at the top. It switches to a compact logo when the sidebar collapses.
NvSidebarheaderOptional area below the logo, for a search field or a workspace switcher.
NvSidebarcontentThe navigation. This is the only part that scrolls.
NvSidebargroupA set of items with an optional label.
NvSidebarnavitemOne destination, or a parent that opens sub-items.
NvSidebarnavsubitemA destination inside a parent item.
NvSidebardividerA line between groups or sections.
NvSidebarfooterStays at the bottom, below the scrolling navigation. Use it for the user, settings or help.

Only NvSidebar and the items you need are required. Leave out the logo, header, groups, dividers or footer when the application has no use for them.

Default

Every item wraps a link that you write. It can be a plain <a> or your router's link component, as long as it renders an <a> with an href. The sidebar never navigates on its own. It does two things with your link:

  • A click anywhere on the row counts as a click on the link, so the icon and the padding are part of the target.
  • The link's href is compared with the sidebar's activePath to mark the current page. See The active page.

Add an icon to every top-level item. A collapsed sidebar shows nothing else.

Sub-items#

Set collapsible on an item and put sub-items (NvSidebarnavsubitem) inside it. They are moved to the item's sub-menu automatically.

vue<NvSidebarnavitem icon="folder" collapsible open>
  <a href="/projects">Projects</a>
  <NvSidebarnavsubitem>
    <a href="/projects/aurora">Aurora</a>
  </NvSidebarnavsubitem>
  <NvSidebarnavsubitem>
    <a href="/projects/atlas">Atlas</a>
  </NvSidebarnavsubitem>
</NvSidebarnavitem>

In an expanded sidebar, clicking a collapsible item opens or closes its sub-menu and does not follow the item's own link. Use a <span> instead of a link when the parent is only a heading. open holds the state and can be set from your code. The sub-menu needs collapsible: without it the sub-items are not shown.

Notifications and trailing content#

notificationCount on an item shows a count at the end of the row, and on the icon when the sidebar is collapsed. A count of 0 shows nothing. The look of all counts is set once on the sidebar, with notificationIntention (brand or neutral) and notificationEmphasis (high or low).

Items and sub-items also have a trailing slot for a tag, a shortcut hint or an icon at the end of the row.

html<span slot="trailing">New</span>

Place it in the page#

The sidebar is as tall as the viewport and takes its width from the theme: 312 px expanded and 80 px collapsed. Put it in a row next to the main area and let the main area scroll:

vue<div class="flex h-screen">
  <NvSidebar>…</NvSidebar>
  <main class="min-w-0 flex-1 overflow-auto">…</main>
</div>

Inside a smaller container, give the sidebar a height of its own, for example class="h-full". The examples on these pages do the same to fit their preview.

The design does not define a mobile layout. On small screens, choose a navigation pattern in your application, such as showing the sidebar in a drawer.