Skip to main content
Light Dark System

Menu Item

<zn-menu-item> | ZnMenuItem
Since 1.0 experimental

Short summary of the component’s intended use.

Menu item
<zn-menu-item>Menu item</zn-menu-item>

Examples

Colors Example

Menu item Menu item Menu item Menu item Menu item Menu item Menu item Menu item
<zn-menu-item>Menu item</zn-menu-item>
<zn-menu-item color="primary">Menu item</zn-menu-item>
<zn-menu-item color="secondary">Menu item</zn-menu-item>
<zn-menu-item color="transparent">Menu item</zn-menu-item>
<zn-menu-item color="error">Menu item</zn-menu-item>
<zn-menu-item color="info">Menu item</zn-menu-item>
<zn-menu-item color="success">Menu item</zn-menu-item>
<zn-menu-item color="warning">Menu item</zn-menu-item>

Keeping the Dropdown Open

A menu item inside a zn-dropdown closes it on select. keep-open exempts a single item, for rows that change how the panel behaves rather than committing a choice — an operator picker above a list of values, say. stay-open-on-select on the dropdown itself still covers every item at once.

Sort Ascending Descending Name Created
<zn-dropdown>
  <zn-button slot="trigger" icon="chevron-down@lu" icon-position="right">Sort</zn-button>
  <zn-menu>
    <zn-menu-item type="checkbox" keep-open checked>Ascending</zn-menu-item>
    <zn-menu-item type="checkbox" keep-open>Descending</zn-menu-item>
    <zn-menu-item value="name">Name</zn-menu-item>
    <zn-menu-item value="created">Created</zn-menu-item>
  </zn-menu>
</zn-dropdown>

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@1.1.164/dist/components/menu-item/menu-item.js"></script>

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

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

To import this component using a bundler:

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

Slots

Name Description
(default) The default slot.
example An example slot.

Learn more about using slots.

Properties

Name Description Reflects Type Default
type The type of menu item to render. To use checked, this value must be set to checkbox. 'normal' | 'checkbox' 'normal'
variant The item’s visual style. A standalone item defaults to navigation styling; a parent zn-menu sets this to dropdown or shell automatically. 'default' | 'dropdown' | 'shell' 'default'
checked Draws the item in a checked state. boolean false
value A unique value to store in the menu item. This can be used as a way to identify menu items when selected. string ''
loading Draws the menu item in a loading state. boolean false
disabled Draws the menu item in a disabled state, preventing selection. boolean false
keepOpen
keep-open
Leaves a containing dropdown open when this item is selected, whatever the dropdown’s own setting. boolean false
flush Removes all padding from the menu item. boolean false
flushX
flush-x
Removes horizontal (left/right) padding only. Ignored if flush is set. boolean false
flushY
flush-y
Removes vertical (top/bottom) padding only. Ignored if flush is set. boolean false
noBorder
no-border
Removes the border from the menu item. boolean false
active Marks the menu item as currently active/selected. boolean false
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Events

Name React Event Description Event Detail
zn-event-name Emitted as an example. -

Learn more about events.

Methods

Name Description Arguments
getTextLabel() Returns a text label based on the contents of the menu item’s default slot. -

Learn more about methods.

Custom Properties

Name Description Default
--example An example CSS custom property.

Learn more about customizing CSS custom properties.

Parts

Name Description
base The component’s base wrapper.

Learn more about customizing CSS parts.

Dependencies

This component automatically imports the following dependencies.

  • <zn-example>