Skip to content

Commit

Permalink
fix(shadcn): do not add outline-ring for v3 (#6814)
Browse files Browse the repository at this point in the history
* fix(shadcn): do not add ring if tailwind v3

* chore: changeset

* test(shadcn): update snapshots
  • Loading branch information
shadcn authored Feb 28, 2025
1 parent bc7df68 commit 8539dd6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-taxis-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn": patch
---

do not add ring for v3
18 changes: 15 additions & 3 deletions packages/shadcn/src/utils/updaters/update-css-vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ export async function transformCssVars(
}

if (config.tailwind.cssVariables) {
plugins.push(updateBaseLayerPlugin())
plugins.push(
updateBaseLayerPlugin({ tailwindVersion: options.tailwindVersion })
)
}

const result = await postcss(plugins).process(input, {
Expand All @@ -118,12 +120,22 @@ export async function transformCssVars(
return output
}

function updateBaseLayerPlugin() {
function updateBaseLayerPlugin({
tailwindVersion,
}: {
tailwindVersion?: TailwindVersion
}) {
return {
postcssPlugin: "update-base-layer",
Once(root: Root) {
const requiredRules = [
{ selector: "*", apply: "border-border outline-ring/50" },
{
selector: "*",
apply:
tailwindVersion === "v4"
? "border-border outline-ring/50"
: "border-border",
},
{ selector: "body", apply: "bg-background text-foreground" },
]

Expand Down
15 changes: 2 additions & 13 deletions packages/shadcn/test/utils/updaters/update-css-vars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("transformCssVars", () => {
@layer base {
* {
@apply border-border outline-ring/50;
@apply border-border;
}
body {
@apply bg-background text-foreground;
Expand Down Expand Up @@ -110,7 +110,7 @@ describe("transformCssVars", () => {
@layer base {
* {
@apply border-border outline-ring/50;
@apply border-border;
}
body {
@apply bg-background text-foreground;
Expand Down Expand Up @@ -176,17 +176,6 @@ describe("transformCssVars", () => {
@apply bg-background text-foreground;
}
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
}
"
`)
})
Expand Down

0 comments on commit 8539dd6

Please sign in to comment.