1<div class="menu-wrapper">2 <vscode-icon3 name="menu"4 size="32"5 id="toggle-menu-button"6 action-icon7 title="Toggle Menu"8 class="toggle-menu-button"9 ></vscode-icon>10 <vscode-context-menu11 id="context-menu"12 class="context-menu"13 ></vscode-context-menu>14</div>
1.menu-wrapper {2 overflow: visible;3 position: relative;4}5 6.toggle-menu-button {7 cursor: pointer;8 display: block;9}10 11.context-menu {12 bottom: 36px;13 left: 16px;14 position: absolute;15 z-index: 2;16}
1const menu = document.querySelector('#context-menu');2const button = document.querySelector('#toggle-menu-button');3 4document.querySelector('#context-menu').data = [5 {6 label: 'Command palette...',7 keybinding: 'Ctrl+Shift+A',8 value: 'menuitem1',9 },10 {11 separator: true,12 },13 {14 label: 'Settings',15 keybinding: 'Ctrl+Comma',16 value: 'menuitem2',17 },18 {19 label: 'Extensions',20 keybinding: 'Ctrl+Shift+X',21 value: 'menuitem3',22 },23];24 25button.addEventListener('click', () => {26 menu.show = !menu.show;27});28 29menu.addEventListener('vsc-context-menu-select', (event) => {30 console.log(event);31});