Skip to content

Commit 8539dd6

Browse files
authored
fix(shadcn): do not add outline-ring for v3 (#6814)
* fix(shadcn): do not add ring if tailwind v3 * chore: changeset * test(shadcn): update snapshots
1 parent bc7df68 commit 8539dd6

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

.changeset/curvy-taxis-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"shadcn": patch
3+
---
4+
5+
do not add ring for v3

packages/shadcn/src/utils/updaters/update-css-vars.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export async function transformCssVars(
100100
}
101101

102102
if (config.tailwind.cssVariables) {
103-
plugins.push(updateBaseLayerPlugin())
103+
plugins.push(
104+
updateBaseLayerPlugin({ tailwindVersion: options.tailwindVersion })
105+
)
104106
}
105107

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

121-
function updateBaseLayerPlugin() {
123+
function updateBaseLayerPlugin({
124+
tailwindVersion,
125+
}: {
126+
tailwindVersion?: TailwindVersion
127+
}) {
122128
return {
123129
postcssPlugin: "update-base-layer",
124130
Once(root: Root) {
125131
const requiredRules = [
126-
{ selector: "*", apply: "border-border outline-ring/50" },
132+
{
133+
selector: "*",
134+
apply:
135+
tailwindVersion === "v4"
136+
? "border-border outline-ring/50"
137+
: "border-border",
138+
},
127139
{ selector: "body", apply: "bg-background text-foreground" },
128140
]
129141

packages/shadcn/test/utils/updaters/update-css-vars.test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe("transformCssVars", () => {
4747
4848
@layer base {
4949
* {
50-
@apply border-border outline-ring/50;
50+
@apply border-border;
5151
}
5252
body {
5353
@apply bg-background text-foreground;
@@ -110,7 +110,7 @@ describe("transformCssVars", () => {
110110
111111
@layer base {
112112
* {
113-
@apply border-border outline-ring/50;
113+
@apply border-border;
114114
}
115115
body {
116116
@apply bg-background text-foreground;
@@ -176,17 +176,6 @@ describe("transformCssVars", () => {
176176
@apply bg-background text-foreground;
177177
}
178178
}
179-
180-
181-
182-
@layer base {
183-
* {
184-
@apply border-border outline-ring/50;
185-
}
186-
body {
187-
@apply bg-background text-foreground;
188-
}
189-
}
190179
"
191180
`)
192181
})

0 commit comments

Comments
 (0)