1.0.9 • Published 1 year ago

context-menu-svelte v1.0.9

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Context menu svelte

A svelte component designed for effortless creation of context menus.

Installation

npm install --save-dev context-menu-svelte

Example

<script>
import {ContextMenu, MenuOption } from "context-menu-svelte";
</script>

<ContextMenu showMenu={true}>
<MenuOption on:click={console.log} text="Add"  />
<MenuDivider />
<MenuOption isDisabled={true} on:click={console.log} text="Go to"  />
</ContextMenu>

Additionally, you can customize the context menu's position and enable auto-hide functionality (when clicking outside the menu).

Usage

To utilize the context menu in a more authentic manner, use like this:

<script>
	let showMenu = false;
	let x = 0;
	let y = 0;
	function requestShowMenu(e){
		showMenu = true;
		x = e.clientX;
		y = e.clientY;
	}
</script>
<div on:contextmenu={requestShowMenu}>Text</div>
<ContextMenu bind:showMenu {x} {y}>
	<MenuOption on:click={console.log} text="Hello world!"/>
</ContextMenu>
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago