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
Could you please reorder the className and variant props in the Badge component? Right now, user-provided classes are always being overridden, which causes them to lose precedence. Reordering these should allow user classes to take priority and resolve the issue.
How to reproduce
Create a Badge using the existing component base-ui.
Pass a custom class such as rounded-sm through the className prop.
Notice that the style does not apply — the default styles from the component override it.
The custom class only works if you force it with rounded-sm!.
After checking the component implementation, I found this line:
className: cn(badgeVariants({ className, variant })),
Because className is passed before variant, the generated variant styles take precedence over user-provided classes.
Normally, it should be ordered like this:
className: cn(badgeVariants({ variant, className })),
This way, user classes are applied last and can properly override the defaults.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Could you please reorder the className and variant props in the Badge component? Right now, user-provided classes are always being overridden, which causes them to lose precedence. Reordering these should allow user classes to take priority and resolve the issue.
How to reproduce
Create a Badge using the existing component base-ui.
Pass a custom class such as rounded-sm through the className prop.
Notice that the style does not apply — the default styles from the component override it.
The custom class only works if you force it with rounded-sm!.
After checking the component implementation, I found this line:
className: cn(badgeVariants({ className, variant })),
ui/apps/v4/registry/bases/base/ui/badge.tsx
Line 36 in 2ef58bd
Because className is passed before variant, the generated variant styles take precedence over user-provided classes.
Normally, it should be ordered like this:
className: cn(badgeVariants({ variant, className })),
This way, user classes are applied last and can properly override the defaults.
Beta Was this translation helpful? Give feedback.
All reactions