Just getting into customizing my Obsidian workspace through CSS snippets recently. Extremely fun and engaging. I am new to CSS as well and am slowly gaining an understanding, but I have hit a wall recently.
I have been going through the Obsidian Dev Documentation over CSS Classes and Variables. Primarily trying to correlate the classes in the snippet I have with the information on the documentation; however it doesn’t seem to line up exactly.
For Example, I have the following snippet which hides properties in Reading Mode.
I want to alter this to hide properties in Live Editing mode (I have since found a solution to that). When breaking it down, I wanted more info on the .workspace-leaf-content class and the data-mode property within. However, the best I could do is the CSS Variable and the TypeScript API in the documentation. Neither of which, from what I could tell, had the documentation for the class specifically. I was able to find it through “inspect element” in the HTML code, but that’s hardly helpful. Additionally, I could not find “data-mode” information anywhere except forum posts. I can find some variables that almost match the class, but in use don’t work as expected.
Am I missing some knowledge of how to interpret the documentation to create and use these classes?
Are the classes specific to Obsidian or some common repo? I couldn’t find them on the Mozilla CSS Docs.
Would appreciate more guidance in this. Feel like I gave it my due diligence before coming here. Thank you!
I don’t think I’ve seen any official Obsidian documentation for data-mode specifically. It’s not in app.css (Obsidian’s default CSS), but it does show up in the DOM/HTML in the DevTools, so you can target it with CSS.
Try searching the web for “CSS attribute selector” or similar.
Seems you’ve sorted it out already, but there are two variables for showing/hiding the metadata editor in the different views that can be used with a cssclass:
For .workspace-leaf-content, I think that is specific to Obsidian, but I’m not really playing around in the dev tools for other apps, so can’t say for sure.
I think of .workspace-leaf and the inner .workspace-leaf-content as the panes in Obsidian.