-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
What version of Tailwind CSS are you using?
For example: v4.1.7
What build tool (or framework if it abstracts the build tool) are you using?
For example: SevlteKit 2.21.1, Vite 6.3.5, @sveltejs/vite-plugin-svelte 5.0.3
What version of Node.js are you using?
Not relevant
What browser are you using?
For example: Chrome, Arc, Brave
What operating system are you using?
For example: macOS
Reproduction URL
Not happening in Tailwind Play, only with Vite plugin.
Here's a link to Tailwind Play where it works correctly (I guess Tailwind Play doesn't use the Vite plugin): https://play.tailwindcss.com/wd6xBLjL8R
Describe your issue
The Vite plugin converts HSL and RGB colors to HEX during build. This can cause problems, as you can see in the example below:
We have a SvelteKit app.
This is the vite.config.ts
:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [tailwindcss(), sveltekit()]
});
In our app.css
we have some gradient stops for the primary color.
@theme inline {
/* Common Tailwind gradient stops for primary color */
--color-primary-50: color-mix(in hsl, var(--primary) 7%, hsl(193deg 100% 100%) 93%);
--color-primary-100: color-mix(in hsl, var(--primary) 20%, hsl(193deg 100% 100%) 80%);
--color-primary-200: color-mix(in hsl, var(--primary) 40%, hsl(193deg 100% 100%) 60%);
--color-primary-300: color-mix(in hsl, var(--primary) 60%, hsl(193deg 100% 100%) 40%);
--color-primary-400: color-mix(in hsl, var(--primary) 80%, hsl(193deg 100% 100%) 20%);
--color-primary-500: var(--primary);
--color-primary-600: color-mix(in hsl, var(--primary) 90%, hsl(193deg 0% 0%) 10%);
--color-primary-700: color-mix(in hsl, var(--primary) 78%, hsl(193deg 0% 0%) 22%);
--color-primary-800: color-mix(in hsl, var(--primary) 65%, hsl(193deg 0% 0%) 35%);
--color-primary-900: color-mix(in hsl, var(--primary) 50%, hsl(193deg 0% 0%) 50%);
--color-primary-950: color-mix(in hsl, var(--primary) 35%, hsl(193deg 0% 0%) 65%);
}
With this we can use gradient stops for the primary color the same way as with the default Tailwind colors.
When I use the class border-primary-200
, I get this code in my dev environment:
.border-primary-200 {
@supports (color: color-mix(in lab, red, red)) {
border-color: color-mix(in hsl, var(--primary) 40%, hsl(193deg 100% 100%) 60%);
}
}
Which looks as expected:
But in the prod environment the color-mix
doesn't work correctly anymore:
@supports (color:color-mix(in lab,red,red)) {
.border-primary-200 {
border-color: color-mix(in hsl, var(--primary) 40%, #fff 60%);
}
}
As you can see the border color for the box in the center looks different: