Skip to content

bug: drawer overlay changing custom data-theme bg to base-100 #4535

Closed

Description

@mangopuree0

Reproduction URL (Required)

https://play.tailwindcss.com/Ar87k1NFdM

What version of daisyUI are you using?

v5.5.19

Which browsers are you seeing the problem on?

Edge

Describe your issue

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.

Image Image

Activity

  1. github-actions commented on May 27, 2026

    @github-actions

    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.

  2. pdanpdan commented on May 27, 2026

    @pdanpdan
    Contributor

    you are using hex colors for your theme, so they cannot be adjusted as needed
    convert your theme to oklch

  3. mangopuree0 commented on May 27, 2026

    @mangopuree0
    Author

    you are using hex colors for your theme, so they cannot be adjusted as needed convert your theme to oklch

    Exactly the same thing happens when I use oklch colours :(

  4. pdanpdan commented on May 27, 2026

    @pdanpdan
    Contributor

    Post the play, please

  5. mangopuree0 commented on May 27, 2026

    @mangopuree0
    Author
  6. saadeghi commented on May 27, 2026

    @saadeghi
    Owner

    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.

  7. mangopuree0 commented on May 27, 2026

    @mangopuree0
    Author

    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-primary

    https://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?

  8. saadeghi commented on May 27, 2026

    @saadeghi
    Owner

    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.

  9. mangopuree0 commented on May 28, 2026

    @mangopuree0
    Author

    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 :-(

  10. saadeghi commented on May 28, 2026

    @saadeghi
    Owner

    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?

  11. mangopuree0 commented on May 28, 2026

    @mangopuree0
    Author

    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

  12. saadeghi commented on May 28, 2026

    @saadeghi
    Owner

    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

    Solution 2: wrap the navbar in a <div data-theme="bt">:
    https://play.tailwindcss.com/ZeDtQGZM1o

    Let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions