Skip to main content
2.0.48
Light Dark System
Compact Comfortable

Menu Group

<zn-menu-group> ZnMenuGroup
Since 2.0 experimental

A navigation row with rows nested under it, joined by a line down from its icon, such as a department and its queues in an app sidebar.

Give an app sidebar’s zn-menu-item rows variant="navigation" for the sidebar look: rounded rows, a fill on hover and for the open page (set active on its row), and the label cut off with an ellipsis. Use count for a count pill. zn-menu-group hangs rows under a parent row (slot="parent"), joined by a line down from its icon, and gives its rows the navigation look itself.

Search Departments Support Email Chat Billing
<div style="width: 240px">
  <zn-menu-item variant="navigation" href="#"><zn-icon slot="prefix" src="search@lu" size="16"></zn-icon>Search</zn-menu-item>
  <zn-menu-label variant="navigation">Departments</zn-menu-label>
  <zn-menu-group>
    <zn-menu-item slot="parent" href="#" count="3"><zn-icon slot="prefix" src="headset@lu" size="16"></zn-icon>Support</zn-menu-item>
    <zn-menu-item href="#" count="1" active><zn-icon slot="prefix" src="mail@lu" size="14"></zn-icon>Email</zn-menu-item>
    <zn-menu-item href="#" count="2"><zn-icon slot="prefix" src="message-circle@lu" size="14"></zn-icon>Chat</zn-menu-item>
  </zn-menu-group>
  <zn-menu-item variant="navigation" href="#" count="0"><zn-icon slot="prefix" src="receipt@lu" size="16"></zn-icon>Billing</zn-menu-item>
</div>

Examples

Folding

Add folded to hide the nested rows, except when one of them is the open page.

Section Headings

A zn-menu-label with variant="navigation" is the sidebar’s section heading, and collapses to a dot. Put controls in its actions slot, such as a settings dropdown’s trigger (icon-button="x-small" fits it): they stay faint until the heading is hovered or focused, or a dropdown among them is open.

Departments Support
<div style="width: 240px">
  <zn-menu-label variant="navigation">
    Departments
    <zn-dropdown slot="actions" placement="right-start" panel>
      <zn-button slot="trigger" icon="ellipsis@lu" icon-button="x-small" plain label="Department settings"></zn-button>
      <zn-toggle label="Hide empty queues" menu></zn-toggle>
    </zn-dropdown>
  </zn-menu-label>
  <zn-menu-item variant="navigation" href="#" count="3"><zn-icon slot="prefix" src="headset@lu" size="16"></zn-icon>Support</zn-menu-item>
</div>

Collapsing With the Shell

Navigation rows, groups and headings collapse together with the shell’s sidebar: rows become icon tiles with their labels in tooltips, the nested rows’ line and indent drop away, and headings become dots. The labels leave before the sidebar narrows and return once it has mostly opened, and each row’s shape morphs into its tile alongside.

The shell calls setNavigationCollapsed as its sidebar starts to open or close, and sets --zn-navigation-duration to the length of its own transition. Every sidebar follows, including those inside app spaces the shell can’t reach, and one that loads later starts in the current state.

import {setNavigationCollapsed} from '@kubex/zinc';

setNavigationCollapsed(true);

Theming

The colours come from --zn-navigation-* variables, which pass down into app spaces, so a shell sets them once on its sidebar for every app’s: --zn-navigation-text, --zn-navigation-hover-text, --zn-navigation-hover-background, --zn-navigation-selected-text, --zn-navigation-selected-background, --zn-navigation-accent, --zn-navigation-border and --zn-navigation-font-size. A shell that paints its own moving selection sets --zn-navigation-selected-background to transparent.

Importing

If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.

To import this component from the CDN using a script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.48/dist/components/menu-group/menu-group.js"></script>

To import this component from the CDN using a JavaScript import:

import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.48/dist/components/menu-group/menu-group.js';

To import this component using a bundler:

import '@kubex/zinc/dist/components/menu-group/menu-group.js';

Slots

Name Description
parent The row the group hangs from.
(default) The nested rows.

Learn more about using slots.

Properties

Name Description Reflects Type Default
folded Hides the nested rows, except when one of them is the open page. boolean false
collapsed Lays the group out for a collapsed sidebar, with no line or indent, following the shell’s sidebar. boolean false
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Custom Properties

Name Description Default
--zn-menu-group-line-color The line joining the nested rows to the parent.

Learn more about customizing CSS custom properties.

Parts

Name Description
children The nested rows’ container, which draws the line.

Learn more about customizing CSS parts.