You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: drawer overlay changing custom data-theme bg to base-100 #4535
I have create a navbar that I am calling "banner" and that is taking a data-theme from a separate variable.
The background is using bg-primary
in the overall app I am using the data-theme "light" where base-100 is white
when I open a drawer the bg of the navbar changes to white and I found out it is using the base-100 of the light theme.
I don't seem to be able to override it and if I use bg-primary on something under the default data theme the background colour doesn't change.
That seems like a lot of waffle but it's obvious in the demo.
Thank you @mattpowell97-1
for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I
find a solution.
In the meantime providing more details and reproduction links would be
helpful.
Background color will be applied to the element that has data-theme attribute. Because when we apply a theme to an element, that element is expected to get the background color of the specified theme. Otherwise nesting a dark theme inside a light theme will end up with a unreadable text color.
I would suggest using data-theme on another element (a parent or a child) not the same element that you want its bg color to be overridden.
on this latest play, everything in the light theme does not change and only the nav bar or the element with data-theme changes
Even hard coding [data-theme="bt"] { background-color: #5514b4; } the background is still overridden.
If the element with data-theme="dark" doesn't set the background color of the dark theme automatically, it will be white text on white background. Unreadable text.
We want all themes to be accessible by default, no matter how they are nested.
So then the issue is with my text the colour of it doesn't change when the background of the dark element turns white.
Are there specific colours that I have set in the theme that are overriding that?
In my app I have just made a new element surrounding my navbar, made it the same size and put the data-theme in there, as you previously suggested.
The work around worked but I am not happy with the solution :-(
I can help better if you explain what's the goal?
Because I'm a little bit confused here.
Do you want the navbar in your first example to use the primary color? If so, primary color of which theme?
The goal is to have the navbar as bg-primary of a custom data-theme which is set based on a var. Then when the drawer opens it needs to not change the background colour of the nav bar
I see.
Solution 1: add a bg-none to your navbar. This prevents the data-theme to set the background property and as a result, bg-primary works: https://play.tailwindcss.com/lIYRV7e2Xt
Activity
github-actions commentedon May 27, 2026
Thank you @mattpowell97-1 for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.
pdanpdan commentedon May 27, 2026
you are using hex colors for your theme, so they cannot be adjusted as needed
convert your theme to oklch
mangopuree0 commentedon May 27, 2026
Exactly the same thing happens when I use oklch colours :(
pdanpdan commentedon May 27, 2026
Post the play, please
mangopuree0 commentedon May 27, 2026
https://play.tailwindcss.com/QjqgXuuVNp?file=css
saadeghi commentedon May 27, 2026
Background color will be applied to the element that has
data-themeattribute. Because when we apply a theme to an element, that element is expected to get the background color of the specified theme. Otherwise nesting a dark theme inside a light theme will end up with a unreadable text color.I would suggest using
data-themeon another element (a parent or a child) not the same element that you want its bg color to be overridden.mangopuree0 commentedon May 27, 2026
I still don't understand why the background colour is changed at all just because the theme is different.
On the rest of the page that is the "light" theme the background does not change even when set to something else eg
bg-primaryhttps://play.tailwindcss.com/3lS5Bwzqdn
on this latest play, everything in the light theme does not change and only the nav bar or the element with data-theme changes
Even hard coding
[data-theme="bt"] { background-color: #5514b4; }the background is still overridden.What is the purpose of that?
saadeghi commentedon May 27, 2026
See this example:
https://play.tailwindcss.com/wNjXd2AWxV
If the element with
data-theme="dark"doesn't set the background color of the dark theme automatically, it will be white text on white background. Unreadable text.We want all themes to be accessible by default, no matter how they are nested.
mangopuree0 commentedon May 28, 2026
So then the issue is with my text the colour of it doesn't change when the background of the dark element turns white.
Are there specific colours that I have set in the theme that are overriding that?
In my app I have just made a new element surrounding my navbar, made it the same size and put the
data-themein there, as you previously suggested.The work around worked but I am not happy with the solution :-(
saadeghi commentedon May 28, 2026
I can help better if you explain what's the goal?
Because I'm a little bit confused here.
Do you want the navbar in your first example to use the primary color? If so, primary color of which theme?
mangopuree0 commentedon May 28, 2026
The goal is to have the navbar as
bg-primaryof a customdata-themewhich is set based on a var. Then when the drawer opens it needs to not change the background colour of the nav barsaadeghi commentedon May 28, 2026
I see.
Solution 1: add a
bg-noneto your navbar. This prevents the data-theme to set thebackgroundproperty and as a result,bg-primaryworks:https://play.tailwindcss.com/lIYRV7e2Xt
Solution 2: wrap the navbar in a
<div data-theme="bt">:https://play.tailwindcss.com/ZeDtQGZM1o
Let me know if you have any questions.