Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CSS variables created by plugins are modified #16100

Closed
siriwatknp opened this issue Jan 31, 2025 · 3 comments · Fixed by #16103
Closed

CSS variables created by plugins are modified #16100

siriwatknp opened this issue Jan 31, 2025 · 3 comments · Fixed by #16103

Comments

@siriwatknp
Copy link
Contributor

What version of Tailwind CSS are you using?

v4.0.1

What operating system are you using?

macOS

Reproduction URL

  • Pull tailwindcss project
  • Add the test below to packages/tailwindcss/src/plugin.test.ts
diff --git a/packages/tailwindcss/src/plugin.test.ts b/packages/tailwindcss/src/plugin.test.ts
index 9af3a55f..89129df7 100644
--- a/packages/tailwindcss/src/plugin.test.ts
+++ b/packages/tailwindcss/src/plugin.test.ts
@@ -32,6 +32,36 @@ test('plugin', async () => {
   `)
 })
 
+test('plugin CSS variables', async () => {
+  let input = css`
+    @plugin "my-plugin";
+  `
+
+  let compiler = await compile(input, {
+    loadModule: async () => ({
+      module: plugin(function ({ addBase }) {
+        addBase({
+          body: {
+            '--jun-drawerOpen': '1',
+            '--jun-ES-drawerWidth': '18rem',
+          },
+        })
+      }),
+      base: '/root',
+    }),
+  })
+
+  expect(compiler.build([])).toMatchInlineSnapshot(`
+    "@layer base {
+      body {
+        --jun-drawerOpen: 1;
+        --jun-ES-drawerWidth: 18rem;
+      }
+    }
+    "
+  `)
+})
+
 test('plugin.withOptions', async () => {
   let input = css`
     @plugin "my-plugin";

Run the test to see the error:

Image

Describe your issue

Tailwind CSS should not modify the CSS variables created by plugins.

@siriwatknp
Copy link
Contributor Author

Seems like it's coming from

name = name.replace(/([A-Z])/g, '-$1').toLowerCase()
.

I can create a PR if this issue is labeled as a bug.

@RobinMalfait
Copy link
Member

RobinMalfait commented Jan 31, 2025

Thanks for the bug report and the fix! This will be available in the next release, or you can try to use the insiders build which will have the fix available soon:

  • npm install tailwindcss@insiders

@siriwatknp
Copy link
Contributor Author

Thanks for the bug report and the fix! This will be available in the next release, or you can try to use the insiders build which will have the fix available soon:

  • npm install tailwindcss@insiders

Thanks! FYI, I have to update @tailwindcss/postcss too. Updating tailwindcss alone does not work.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants