Lightweight Javascript Library To Create A Custom Context Menu For Your Website

ContextMenu.js is a lightweight context menu JavaScript library that allows you to associate any actions with menu items.

custom context menu codepen, custom context menu jquery, js custom context menu, custom context menu react, custom right click menu html, javascript context menu example

How to make use of it:

1. Import Contextmenu.js into your document.

<script src="./src/contextMenu.min.js" ></script>

2. Select a set of menu items as follows:

const menuItem = [
      {
        template: "<span>Menu Item 1</spa>",
        onClick : function(){
          // do something
        }
      },
      {
        template: "<span>Menu Item 2</spa>",
        onClick : function(){
          // do something
        }
      },
      {
        template: "<span>Menu Item 3</spa>",
        onClick : function(){
          // do something
        }
      },
]

3. Configure the context menu and attach it to the target item you select.

contextMenu({
  items: menuItems
}).init(document.getElementById("myContainer"));

4. Apply your own CSS styles to the context menu.

.contextMenu{
  background-color: #7d5fff;
}

.contextMenuItem{
  transition: all 0.4s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  align-content: center;
  padding: 10px;
  color:#fff;
}

.contextMenuItem:hover{
  background-color: #5f27cd;
  color:#fff;
}

5. Customize CSS class and context menu identifier.

contextMenu({
  items: menuItems,
  className: "myClassName",
  id:"myId",
}).init(document.getElementById("myContainer"));

Lightweight Custom Context Menu In Vanilla JavaScript, ContextMenu.js Plugin/Github, custom right click menu chrome


See Demo And Download

Official Website(mboussaid): Click Here

This superior jQuery/javascript plugin is developed by mboussaid. For extra Advanced Usages, please go to the official website.

Related Posts

Iconpicker-Bootstrap-5

[Icon Picker] Iconpicker for Bootstrap 5 Icons Library

Bootstrap 5-based icon picker which supports any icon libraries like Bootstrap Icons, Font Awesome[fontawesome.com], etc. Must Read: 1000+ Pixel Perfect SVG Icons For Vue Components | Unicons How…

bootstrap-multiple-image-upload-with-preview

Bootstrap Multiple Image Upload with Preview and Delete | ImagesLoader

ImagesLoader is a standard bootstrap image upload plugin that provides an easy-to-use and nice-looking interface for uploading multiple images to a web server. Must Read: HTML 5…

Animating-Split-Flap-Displays-fallblatt

A Lightweight jQuery Plugin for Animating Split-Flap Displays | fallblatt

fallblatt is a lightweight jQuery plugin for animating split screens. This jQuery plugin allows you to include such offers in your web application. Everything from virtual departure…

bootstrap-5-dark-theme

Dark & Light Switch Mode Toggle for Bootstrap 5

Switching to dark mode is done by toggling HTML tags that include -dark or -light as a category. It is made by manipulating the DOM with JavaScript. The text color also changes depending…

jQuery-SyoTimer-Plugin

jQuery Plugin for Countdown Timer on HTML Page | SyoTimer

yoTimer jQuery plugin allows you to create digital style countdowns/periodic timers on the webpage, with callbacks support and timezone/translation customization. Features Periodic count with the specified period…

vue-js-periodic-table

Dynamic, Data-driven Periodic Table built with Vue.js

Periodicity is a dynamic, data-driven periodic table created with Vue.js that uses D3 animations and graphs to show the beauty of periodic trends. Built With vue.js (component…