@pbhope I’m glad you like it.
You can change the CSS quite easily to accomplish what you are looking for.
Changing Folder Target
The first thing you want to change is to not just target the top level folders. This can be done by simply changing the CSS from targeting the direct child of the root folder to any child. This is done by replacing the “>” symbol between “.nav-folder-children” and “.nav-folder” with a space.
So go from this:
.nav-folder.mod-root>.nav-folder-children>.nav-folder>.nav-folder-title[data-path^="0"],
.nav-folder.mod-root>.nav-folder-children>.nav-folder>.nav-folder-title[data-path^="0"] + .nav-folder-children{
background-color:var(--Fold0)}
To this:
.nav-folder.mod-root>.nav-folder-children .nav-folder>.nav-folder-title[data-path^="0"],
.nav-folder.mod-root>.nav-folder-children .nav-folder>.nav-folder-title[data-path^="0"] + .nav-folder-children{
background-color:var(--Fold0)}
Adjusting the Regex
If you have done this, you won’t notice a difference… yet.
The original snippet uses the [data-path^=“0”] to target a datapath that starts with the desired character. In your case, you still want this to be the case, however, obsidian includes the parent folders in the data path. This is why you are not seeing any change yet.
This means that for your example case, the data path for you first sub folder is not “100 Folder A” but is rather "Folder 1/100 Folder A
So any folder inside Folder A will have a data path that starts with that folder name.
We can adjust the regex to target the sub-folder, however.
We want to instead target data paths that have any number of characters followed by a “/” then a digit. We do this by calling “contains” which is “=" instead of the “starts with” which is “^=”
So we change from: [data-path^=“0”] to [data-path=”/0"]
Alternate Option
The one downside to this is that as soon as you have a folder that contains a “/” and a number, all sub folders of that folder will also contain that “/” and number in their data path.
If you don’t want this behaviour, the best option is to use the end of the folder as your designation instead of the start. This will eliminate sub-folders being selected based on their parent folder.
For example:
Using [data-path$=“0”] will target any data path that ends with a zero.
Then name your folder “Folder A -0” to have it apply. If you then have a sub folder named “subfolder example” its data path will be “Folder 1/Folder A -0/subfolder example” and will not be selected since it doesn’t end with the zero.
Let me know if you have any more questions.