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: @apply btn btn-primary inside @layer base is overridden by Tailwind preflight (sublayer base.daisyui has lower priority) #4812
When daisyUI classes are used with @apply inside @layer base, the resulting styles are placed in a nested sublayer (base.daisyui). Under CSS cascade layer rules, styles declared directly in a parent layer beat styles in its nested sublayers, so Tailwind's preflight (declared in base) overrides the daisyUI styles regardless of specificity or source order.
I reproduced this with btn btn-primary. I haven't tested other daisyUI classes, so I don't know whether the problem is specific to some classes or affects all of them.
Thank you @Predota
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.
Neither daisyui not tailwind promote the use of complex classes using @apply.
The mechanism to use @apply works like this - it includes the rules to be applied in the place where the @apply rule is present.
But what is the point of what you are doing, maybe there is a simple normal solution?
If you want to just create shortcuts then put them in the components layer which is between base and utility
Moving the rule to @layer components works as a workaround, but then the defaults are no longer overridable by other base-level rules, which was the point of putting them in base.
Thanks, I know the components layer works. My point is that defining overridable defaults for elements (buttons, links, etc.) in base was supported before 5.3.0 and no longer is. Was that change intentional?
To be clear on the scope: is @apply of daisyUI classes (e.g. @apply btn btn-primary) in @layer components supported, or is @apply of daisyUI classes not supported at all?
i think this can be closed - the daisyui sublayer is a design decision needed to allow tailwind utilities to have priority, and tailwind addComponents does not add to components layer but to utilities layer (so there is no way to place css in components layer from plugin)
Activity
github-actions commentedon Oct 14, 2026
Thank you @Predota 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 Oct 14, 2026
Neither daisyui not tailwind promote the use of complex classes using
@apply.The mechanism to use
@applyworks like this - it includes the rules to be applied in the place where the@applyrule is present.But what is the point of what you are doing, maybe there is a simple normal solution?
If you want to just create shortcuts then put them in the
componentslayer which is betweenbaseandutilityPredota commentedon Oct 15, 2026
The goal is to define overridable defaults for buttons, links, etc. This use case was supported before 5.3.0.
Working (pre-5.3.0): https://stackblitz.com/edit/daisyui5-jmumostu
Moving the rule to
@layer componentsworks as a workaround, but then the defaults are no longer overridable by otherbase-level rules, which was the point of putting them inbase.pdanpdan commentedon Oct 15, 2026
the order is:
you can overwrite them if you want like in https://play.tailwindcss.com/hxQ4G3TuIZ
Predota commentedon Oct 15, 2026
Thanks, I know the
componentslayer works. My point is that defining overridable defaults for elements (buttons, links, etc.) inbasewas supported before 5.3.0 and no longer is. Was that change intentional?pdanpdan commentedon Oct 15, 2026
It was never supposed to be used like that.
Predota commentedon Oct 15, 2026
To be clear on the scope: is
@applyof daisyUI classes (e.g.@apply btn btn-primary) in@layer componentssupported, or is@applyof daisyUI classes not supported at all?pdanpdan commentedon Oct 15, 2026
From my pov it is not supported neither by tailwind nor by daisyui, except for simple utilities.
tailwindlabs/tailwindcss#7651
But it probably works on condition that:
The normal design is to create components that apply the desired classes.
Predota commentedon Oct 15, 2026
Ok, it felt like a regression to me. I'll go a different route.
pdanpdan commentedon Nov 15, 2026
i think this can be closed - the daisyui sublayer is a design decision needed to allow tailwind utilities to have priority, and tailwind addComponents does not add to components layer but to utilities layer (so there is no way to place css in components layer from plugin)