Svelte context action provides a svelte action to create highly configurable context/right click menus.
$ npm install svelte-context-action
$ yarn add svelte-context-action
$ pnpm add svelte-context-action
<script>
import { contextMenu } from 'svelte-context-action';
</script>
<div
use:contextMenu={{
items: [
{
type: 'button',
content: 'Hello world',
callback: () => window.alert('hi')
},
{
type: 'button',
content: 'Hi 1',
callback: () => window.alert('hi')
},
{
type: 'divider'
},
{
type: 'button',
content: 'Hi 2',
callback: () => window.alert('hi')
}
],
}}
>
Right click me!
</div>
Documentation is available using a GitHub Wiki here.