# How can I fix and customize my css snippet that changes the color of folders?

**URL:** <https://forum.obsidian.md/t/how-can-i-fix-and-customize-my-css-snippet-that-changes-the-color-of-folders/92704>\
**Category:** Devs: Theme Design & Custom CSS\
**Tags:** custom-css\
**Created:** [December 4, 2024, 7:26am UTC](https://forum.obsidian.md/t/how-can-i-fix-and-customize-my-css-snippet-that-changes-the-color-of-folders/92704 "2024-12-04T07:26:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guedes.md](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/8797f3/32.png) [@guedes.md](https://forum.obsidian.md/u/guedes.md)\
**Post date:** [December 4, 2024, 7:26am UTC](https://forum.obsidian.md/t/how-can-i-fix-and-customize-my-css-snippet-that-changes-the-color-of-folders/92704/1 "2024-12-04T07:26:19Z")

</div>

the main folders, those that come after my vault, are not working.  
 ![image](https://forum.obsidian.md/uploads/default/original/3X/3/3/3303a88e1c283851200119d1f3ff0e9ece1afc52.png)  
I also wanted to know how I can make the notes be included in the folder color  
 ![image](https://forum.obsidian.md/uploads/default/original/3X/b/7/b7342e3496dec5692e7a56aedefb152981800d63.png)

 ![image](https://forum.obsidian.md/uploads/default/original/3X/1/7/1785c79b91c4e48086d1e56859c5c9181036259b.png)  
I’m using the ones marked in green to edit the code, since it’s similar.

> [@Iterative Rainbow Folder Colors css](https://forum.obsidian.md/t/iterative-rainbow-folder-colors-css/21066):
>
> Iterative Rainbow Folder Colors css I’m coming into Obsidian from onenote and one thing I missed from that app was the intuitive color coding of tabs, which made it easy to visually differentiate folders. And I just really like the aesthetics. So, with a lot of help from @SIRvb, and inspired by the [Adding Color to Obsidian](https://forum.obsidian.md/t/adding-color-to-obsidian-a-rainbow-of-possibility/12805) forum thread, we’ve come up with the following (left to right). The attached css files iteratively color folders in a 9 color repeating rainbow pattern up to three levels d…

the one in red didn’t work

> [@Minimalist colored folders](https://forum.obsidian.md/t/minimalist-colored-folders/54032):
>
> Hi all, I’ve been looking for a way to add color to my folders. I tried the snippets created by [Lithou](https://forum.obsidian.md/t/adding-color-to-obsidian-a-rainbow-of-possibility/12805/11) and [pbhopeful](https://forum.obsidian.md/t/iterative-rainbow-folder-colors-css/21066) but I wanted something more minimalist. So I made some changes and created two versions. The first version “title only” will add a background to the title of top-level folders only. The second version will add a background to top-level folder and all of their contents. Colors and opacity can be modified at the top of the CSS file. The snippets don’t make any change to typograph…

---

<div class="post-metadata">

**Author:** ![drodark5](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/c0e974/32.png) [@drodark5](https://forum.obsidian.md/u/drodark5)\
**Post date:** [December 16, 2024, 3:39am UTC](https://forum.obsidian.md/t/how-can-i-fix-and-customize-my-css-snippet-that-changes-the-color-of-folders/92704/2 "2024-12-16T03:39:08Z")

</div>

Sadly no solution here, came to post pretty much the exact issue where the root folders aren’t working, then found yours. If you find a solution elsewhere, please share it here

---

<div class="post-metadata">

**Author:** ![yen\_le](https://forum.obsidian.md/user_avatar/forum.obsidian.md/yen_le/32/61132_2.png) [@yen\_le](https://forum.obsidian.md/u/yen_le)\
**Post date:** [December 19, 2024, 11:10pm UTC](https://forum.obsidian.md/t/how-can-i-fix-and-customize-my-css-snippet-that-changes-the-color-of-folders/92704/3 "2024-12-19T23:10:22Z")

</div>

Here is my folder tree looks like. Hope the snippet is somewhat you need.

I use default theme with colors in Flexoki palette.

 ![image](https://forum.obsidian.md/uploads/default/original/3X/e/4/e481fcaba56e74d32ec84acd910ad87bf072233d.png)

```css
.tree-item-self.nav-folder-title.fn-is-active,
.tree-item-self.nav-file-title.fn-is-active,
.nav-folder-title.is-active,
.nav-file-title.is-active {
    background-color: var(--background-modifier-hover);
}

.nav-files-container>div {

    >.tree-item:nth-of-type(8n+1) * {
        --folder-color: var(--color-pink);
        --folder-color-rgb: var(--color-pink-rgb);
    }

    >.tree-item:nth-of-type(8n+2) * {
        --folder-color: var(--color-red);
        --folder-color-rgb: var(--color-red-rgb);
    }

    >.tree-item:nth-of-type(8n+3) * {
        --folder-color: var(--color-orange);
        --folder-color-rgb: var(--color-orange-rgb);
    }

    >.tree-item:nth-of-type(8n+4) * {
        --folder-color: var(--color-yellow);
        --folder-color-rgb: var(--color-yellow-rgb);
    }

    >.tree-item:nth-of-type(8n+5) * {
        --folder-color: var(--color-green);
        --folder-color-rgb: var(--color-green-rgb);
    }

    >.tree-item:nth-of-type(8n+6) * {
        --folder-color: var(--color-cyan);
        --folder-color-rgb: var(--color-cyan-rgb);
    }

    >.tree-item:nth-of-type(8n+7) * {
        --folder-color: var(--color-blue);
        --folder-color-rgb: var(--color-blue-rgb);
    }

    >.tree-item:nth-of-type(8n+8) * {
        --folder-color: var(--color-purple);
        --folder-color-rgb: var(--color-purple-rgb);
    }

    >.tree-item {

        * {
            --nav-item-color-active: var(--folder-color);
            --nav-item-background-active: var(--background-modifier-hover);
            --nav-item-background-hover: rgba(var(--folder-color-rgb), var(--folder-hover-opacity));
            --nav-indentation-guide-color: rgba(var(--folder-color-rgb), var(--folder-indentation-opacity));
        }

        .tree-item-children {
            border-inline-start: var(--nav-indentation-guide-width) solid var(--nav-indentation-guide-color);
        }

        .nav-folder-title {
            --nav-item-color-hover: var(--folder-color);
            --nav-collapse-icon-color: var(--folder-color);
            --nav-item-color: var(--folder-color);
        }

        .nav-file-title:hover,
        .tree-item-self.fn-is-active:hover {
            background-color: rgba(var(--folder-color-rgb), var(--folder-hover-opacity));
        }
    }
}

```
