I want to make the button icon change depending on whether the source view is enabled or not.
On the forum I found a thread where the icons of the reading/editing view button were changed - Swap icons in editor v reading view?, where it was said about the html parameter that changed relative to the view mode (reading/editing view) - this is data-mode, where the icon was changed relative to this parameter.
Does the source view button have any parameter?
(Sorry for my English)
Switching between the source view and editing view modes (obviously, I don’t use the reading view), I noticed that a certain class is changing.
In source view mode, this class looks like this:
For Source mode, use .markdown-source-view:not(.is-live-preview).
For Live Preview, use .markdown-source-view.is-live-preview.
edit:
My mistake, that won’t work! It’s because the header (where your new icon is) is before (i.e., outside) of the content described by the selectors that I wrote. When I get a chance, I’ll take a look to see exactly how you would have to write it to make it work. For a CSS solution, it will probably require something called a :has pseudo class which might slow down your Obsidian experience, but I’ll try it out later to find out.
Okay, got it working! I saw your other thread where ariehen and DiCaver helped you hide the Reading icon, and I see the icon that you’re wanting to use in Source mode. You can use this code below.
Great! I changed the code a little bit (aria-label^=“...”) because the icon was changing for the wrong button (I think it’s my fault for not explaining what I needed). The code works great with different themes and so on, and is a very good basis for other css-snippets. Thank you very much for your help