JSPM

@vaadin/context-menu

22.0.0-alpha8
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 39530
  • Score
    100M100P100Q153074F
  • License Apache-2.0

Web Component for showing context dependent items for any element on the page

Package Exports

  • @vaadin/context-menu
  • @vaadin/context-menu/src/vaadin-context-menu.js
  • @vaadin/context-menu/theme/lumo/vaadin-context-menu.js
  • @vaadin/context-menu/theme/material/vaadin-context-menu.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@vaadin/context-menu) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

<vaadin-context-menu>

Live Demo ↗ | API documentation ↗

<vaadin-context-menu> is a Web Component providing a contextual menu, part of the Vaadin components.

npm version Published on Vaadin Directory Discord

<vaadin-context-menu>
  <span>Open a context menu with <b>right click</b> or with <b>long touch.</b></span>
</vaadin-context-menu>

<script>
  const contextMenu = document.querySelector('vaadin-context-menu');
  contextMenu.renderer = function (root) {
    let listBox = root.firstElementChild;
    // Check if there is a list-box generated with the previous renderer call to update its content instead of recreation
    if (listBox) {
      listBox.innerHTML = '';
    } else {
      listBox = document.createElement('vaadin-list-box');
      root.appendChild(listBox);
    }

    ['First', 'Second', 'Third'].forEach(function (name) {
      const item = document.createElement('vaadin-item');
      item.textContent = name + ' menu item';
      listBox.appendChild(item);
    });
  };
</script>

Screenshot of vaadin-context-menu

Note: <vaadin-list-box> component used in the above example should be installed and imported separately.

Installation

Install vaadin-context-menu:

npm i @vaadin/context-menu --save

Once installed, import it in your application:

import '@vaadin/context-menu/vaadin-context-menu.js';

Getting started

Vaadin components use the Lumo theme by default.

To use the Material theme, import the correspondent file from the theme/material folder.

Entry points

  • The component with the Lumo theme:

    theme/lumo/vaadin-context-menu.js

  • The component with the Material theme:

    theme/material/vaadin-context-menu.js

  • Alias for theme/lumo/vaadin-context-menu.js:

    vaadin-context-menu.js

Contributing

Read the contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.

License

Apache License 2.0

Vaadin collects development time usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.