Open SDrinkwater opened 1 month ago
https://github.com/user-attachments/assets/d4925e6b-fc92-497f-b558-a5ef99f39f83
I am experiencing the same bug.
I think it's the logic that clears the “css” variable in the “next.js” in the updated “cli”. But looking at the logic, it doesn't seem to be effective in clearing the latest “next.js” “css” variable at the moment (v14.2.11)
I don't know if the following modification will work, but I'm open to suggestions and inquiries
function cleanupDefaultNextStylesPlugin() {
return {
postcssPlugin: "cleanup-default-next-styles",
Once(root: Root) {
// Remove specific variables from “:root” rules and delete rules
root.walkRules(":root", (rootRule) => {
rootRule.walkDecls((decl) => {
if (decl.prop === "--background" || decl.prop === "--foreground") {
decl.remove()
}
})
// If the “:root” rule is empty, remove it
if (rootRule.nodes.length === 0) {
rootRule.remove()
}
})
// Remove all declarations from the “body” rule and delete the rule
root.walkRules("body", (bodyRule) => {
bodyRule.remove()
})
},
}
}
The test code for that utility is also not up to date with the latest “next.js”
Probably “next.js” broke the logic of “shadcn” when it updated the “css” variable
@shadcn
Same here, took a while to troubleshoot why the font was Arial and realised the culprit was in globals.css
Describe the bug
Issue: After running
npx shadcn@latest init -d
, the resultingglobals.css
contains both the default NextJS setup as well as the themed css variables. These variables overlap and cause issues with the tailwind setup created via the shadcn command.As a concrete example, the
tailwind.config.ts
background looks like this:background: "hsl(var(--background))"
(note that it expects--background
to be a hsl value. The problem is that the default NextJS setup uses hex for the themed colors. These override the ones specified by the shadcn theme and effectively corrupt the theme. The resulting style given to the browser looks like:Note that it is trying to use a hex value as an hsl value.
Since the value passed to the browser is not valid, it renders the background color as transparent which messes with all of the components that rely on this background theming (read: practically all of them).
I noticed this initially on the slider component as the thumb was entirely transparent.
Expected: The resulting
globals.css
file should not contain the default NextJS setup.Workaround: If others face this issue and notice that their components look a little funny, simply remove the default NextJS theming (first
:root
block through to the first@layer utilities
blockSee the first part of the resulting
globals.css
file below:Affected component/components
All
How to reproduce
npx shadcn@latest init -d
npx shadcn@latest add slider
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting