Black Lives Matter. Please consider donating to Black Girls Code today.

Change the color for active item in my sidebar

Hello, i’m working with dash and i used the code in documentation for sidebar:
nav = dbc.Nav(
dbc.NavItem(dbc.NavLink(“Active”, active=True, href="#")),
dbc.NavItem(dbc.NavLink(“A link”, href="#")),
dbc.NavItem(dbc.NavLink(“Another link”, href="#")),
dbc.NavItem(dbc.NavLink(“Disabled”, disabled=True, href="#")),
i used “pill” to indicate Active items but i want to change the color for active item , is there a way to do that?

You need to write a bit of custom CSS to overwrite the Bootstrap styles. Something like this should do the trick

.nav-pills {
    color: #fff;
    background-color: orange;

I saved that in a file assets/custom.css and ran the example app I think you’re looking at and saw this.


Change background-color to whatever you want, and color to whatever color you want the text to be.

1 Like

It works! Thank you very much tcbegley.