Replies: 11 comments 2 replies
-
There is no API to customize the look of the context menu except for writing/overwriting CSS |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Any update?? |
Beta Was this translation helpful? Give feedback.
-
I've been overwriting CSS for a few versions and it does change so I've been operating under the assumption it is non public and will change at any moment. I would LOVE for this to be a supported feature. |
Beta Was this translation helpful? Give feedback.
-
Seems like since version 0.21 it's no longer possible to style using CSS (the context menu is rendered inside a shadow root). This makes this issue more important IMO. |
Beta Was this translation helpful? Give feedback.
-
I would really like to change the background colour of the context menu |
Beta Was this translation helpful? Give feedback.
-
Any news regarding this? |
Beta Was this translation helpful? Give feedback.
-
It does drive me a little nuts because I can see VSCode customizing the appearance and including other features like submenus #1947 but none of these key features make it back upstream. |
Beta Was this translation helpful? Give feedback.
-
@smiles2424 are you still able to overwrite css or it is impossible now because of what guykr mentioned above? |
Beta Was this translation helpful? Give feedback.
-
It is possible by overriding services when creating the editor. For contextMenu, you can always pass 'contextMenuService' with instance of IContextMenuService class. Take a look at the default implementation to create your own. monaco.editor.create(document.getElementById("editor"), {}, {
'contextMenuService': {
showContextMenu: (b) => console.log(b)
}
}) |
Beta Was this translation helpful? Give feedback.
-
i found a way to easily style it; add this to your editor creation to disable the shadow dom. const editor = monaco.editor.create(container, {
useShadowDOM: false,
} than you can style it like this for example: .monaco-menu {
background-color: var(--darker);
color: var(--textColor);
border: 1px solid var(--borderColor);
border-radius: 5px;
position: fixed;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.monaco-menu .monaco-menu {
margin-top: -35px;
/* Moves the submenu up by 35px */
}
.monaco-menu .action-item {
height: 30px;
position: relative;
}
.monaco-menu .action-item:last-child {
margin-bottom: -4px;
}
.monaco-menu .action-item:first-child {
margin-top: -4px;
}
.monaco-menu .action-item:hover {
background-color: var(--hover);
}
/* this is the dividers */
.monaco-menu .disabled {
max-height: 1px;
background-color: var(--borderColor);
cursor: default;
} hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Monaco version 0.11.1--
I would like to customize the appearance of the context menu. I can achieve that easily by overwriting the CSS but it doesn't seem like that the CSS is a part of public API? or is it? Is there another way to customize the context menu appearance?
Beta Was this translation helpful? Give feedback.
All reactions