How to hide some context menu items?

Things I have tried

I’ve tried to use dev-tool to help me find out the name of the items that I want to hide, but they’re the same name. I can’t hide one of them; I can only hide all of them.

This is what I’ve tried, but this is only making all my context menu items hidden, that not I want!

div.menu-item {
    display: none !important;
    visibility: hidden;
}

What I’m trying to do

I want to find a way to hide some specific context menu items that are useless to me, for example, “Set as attachment folder” or “Open local graph” or the items from the plugins that I’ve installed.

1 Like

further question

The further question is how can I hide the buttons using the same name in the dev-tool? Because some buttons in Obsidian I’ll never use, and they’re so annoying.

Is this what you’re looking for?

I’m sorry, this is not, and I’ve already seen “this”. And your snippet doesn’t work by the way, you can’t hide “Help” or “Settings” or “Open another vault”.

What I am looking for is to hide a particular item from your right-click to a folder or a note.

And for hide the icon from the right sidebar Customizable Sidebar is helpful.

It would be best if you tried the snippet I gave above, and you’ll see what exactly what do I mean.

No way, look what I’ve found.

div.workspace-ribbon {
    display: none !important;
    visibility: hidden;
}

Use this if you want to completely hide the left sidebar!!!

Sorry about that. “Specific context menu items” gave me the impression you wanted to hide some (or all) of the icons, not the whole sidebar.

In case you ever need them again but want them visually tucked away, quite a few themes have features that hide the sidebar until you hover the left side of the window.

Glad you found a solution that works for you.

No, why you can’t understand me.

I don’t want to hide this (left sidebar ribbon):

But, I want this (context menu items):

To become this (some context menu items are hidden):

Ah, now I understand what you’re after. Yes, I was indeed looking at the wrong menu.

After some digging, unfortunately I cannot see any way to target these items individually with css, as they all have the same class of menu-item with no additional attributes.
Looks like a job for a plugin. I can’t recall seeing any that looked to this particular menu, but perhaps someone out there knows of one, or could look into making one. That’s above my skillset.

If you don’t get any other answers here, I’d suggest opening a plugin request that looks to remove unwanted elements from this menu. It’s possible there are others who wish for the same amount of control.

Lastly, I am able to hide the ‘Settings’, ‘Help’, and ‘Open another vault’ icons with the following. Note this will not remove the whole left sidebar, just the icons.

div[aria-label = "Settings"]{
  display: none;
}
div[aria-label = "Help"]{
  display: none;
}
div[aria-label = "Open another vault"]{
  display: none;
}

It doesn’t look like you’re using a theme, but perhaps some other active code is interfering with this? You could try adding an !important flag after each, like so:

div[aria-label = "Settings"]{
  display: none !important;
}

If this works, you have something else interfering with the ‘standard’ app styling.

Sorry I can’t be of more help on your primary question.

1 Like

OK, I see. Maybe it is impossible to use snippets for this question.

Thanks again for your answers.

I came here looking for the exact same solution; specifically to hide the “Set as attachment folder” context menu, which I have accidentally selected several times because it’s right next to the New Folder menu item.

Why does it even need to be visible when the option to save in a sub-folder has already been set? It makes sense if you have specified one folder location for attachments (because you may want to change it) but if you have selected to always put attachments in the current folder location (or into a sub-folder of the current location) then the ‘Set as attachment folder’ menu is redundant because all it does is mess up your settings if it’s accidentally clicked.

I am surprised to hear that there is not even any way to hide it using css. I was trying various things for at least an hour, and wondering why nothing worked.

1 Like

In a CSS snippet you could use the nth-child or nth-of-type pseduo-class to hide the undesired menu items (for example, the third, fourth, and sixth .menu-item).

You may want to check if the .menu-item class is used elsewhere, and target more specifically (like .file-manager .context-menu .menu-item, as a made-up example) to avoid hiding other items.

If the number of items in the menu changes (due to updates or plugins), you’ll need to update the snippet.

No, I’ve already tried it, and it didn’t work.

OK, I looked at the markup and I don’t see any way to distinguish one context menu from another, so my suggestion won’t work. Whether you right-click on a file in the file manager or a heading in a note, you get the same markup.

It might be worth filing a feature request for better markup.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.