Angular playground

Nova v3.38.0

Preview

Angular

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. nv-sidebar 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#

ElementWhat it is for
nv-sidebarThe frame. It holds the mode (type, open), the current route (activePath) and the width.
nv-sidebarlogoLogo and product name at the top. It switches to a compact logo when the sidebar collapses.
nv-sidebarheaderOptional area below the logo, for a search field or a workspace switcher.
nv-sidebarcontentThe navigation. This is the only part that scrolls.
nv-sidebargroupA set of items with an optional label.
nv-sidebarnavitemOne destination, or a parent that opens sub-items.
nv-sidebarnavsubitemA destination inside a parent item.
nv-sidebardividerA line between groups or sections.
nv-sidebarfooterStays at the bottom, below the scrolling navigation. Use it for the user, settings or help.

Only nv-sidebar 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 (nv-sidebarnavsubitem) inside it. They are moved to the item's sub-menu automatically.

html<nv-sidebarnavitem icon="folder" [collapsible]="true" [open]="true">
  <a href="/projects">Projects</a>
  <nv-sidebarnavsubitem>
    <a href="/projects/aurora">Aurora</a>
  </nv-sidebarnavsubitem>
  <nv-sidebarnavsubitem>
    <a href="/projects/atlas">Atlas</a>
  </nv-sidebarnavsubitem>
</nv-sidebarnavitem>

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:

html<div class="flex h-screen">
  <nv-sidebar>…</nv-sidebar>
  <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.