tailwindcss/packages
Robin Malfait 7b75b1a6ed
Fix opacity modifier using CSS variables (#14916)
When using an opacity modifier such as `bg-black/[var(--opacity)]`, then
this was translated to:
```css
.bg-black\/\[var\(--opacity\)\] {
  background-color: color-mix( in oklch, var(--color-black, #000) calc(var(--opacity) * 100%), transp
}
```

The issue is that this part: `calc(var(--opacity) * 100%)` is invalid
_if_ the `var(--opacity)` already contains a percentage value. See:
https://play.tailwindcss.com/xz0t

This is because this eventually resolves to `calc(20% * 100%)` and `20%
100%` is invalid in CSS.

In Catalyst we use variables like that _with_ the `%` included, which
means that v4 doesn't work as expected when using this.

A variable with a `%` included is probably the better value to support
compared to the the unit less one. This also allows you to define your
variables using `@property` as a proper `<percentage>` type.

Unfortunately the `var(--opacity)` is a value that can change at
runtime, so we don't know the type at compile time.

In the future we might be able to use `first-valid(…)` (see:
https://drafts.csswg.org/css-values-5/#f and generate both versions at
the same time.

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2024-11-08 15:17:03 +00:00
..
@tailwindcss-cli Optimize generated CSS output (#14873) 2024-11-06 11:39:09 +00:00
@tailwindcss-node Rewrite urls in CSS files when using Vite (#14877) 2024-11-07 09:51:58 -05:00
@tailwindcss-postcss Rename --font-size-* variables to --text-* (#14909) 2024-11-07 14:08:06 -05:00
@tailwindcss-standalone Prepare v4.0.0-alpha.31 release (#14823) 2024-10-30 07:53:51 -04:00
@tailwindcss-upgrade Allow newlines and tabs in the argument list of the theme() function (#14917) 2024-11-08 10:14:11 -05:00
@tailwindcss-vite Apply non-Tailwind CSS transforms in Vite plugin (#14871) 2024-11-07 16:26:18 +01:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Fix opacity modifier using CSS variables (#14916) 2024-11-08 15:17:03 +00:00
tsconfig.base.json introduce v4 codebase 2024-03-05 14:29:15 +01:00