tailwindcss/packages
Robin Malfait c46f654fa0
Ensure --alpha(…) is seen as a color, and --spacing(…) is seen as a length (#20260)
This PR fixes an issue where intellisense recommends this
canonicalization:

```diff
- text-[calc(var(--spacing)*4)]
+ text-[--spacing(4)]
```

Which is correct, but the issue is that the result is different due to
ambiguity of the `text-*` utilities.

```css
.text-\[calc\(var\(--spacing\)\*4\)\] {
  font-size: calc(var(--spacing) * 4);
}
.text-\[--spacing\(4\)\] {
  color: calc(var(--spacing, 0.25rem) * 4);
}
```

Notice that we're using `color` all of a sudden? This is because that's
the default and we infer the data type based on the arbitrary value. The
`calc(…)` infers that the type is `length`, but we don't know what the
type of `--spacing(…)` is so we fallback to the default type which would
be `color`.

This PR makes sure that built in functions like `--alpha(…)` and
`--spacing(…)` are resolved as `color` and `length` respectively.

With this fix in place, this is the result:
```css
.text-\[calc\(var\(--spacing\)\*4\)\] {
  font-size: calc(var(--spacing) * 4);
}
.text-\[--spacing\(4\)\] {
  font-size: calc(var(--spacing, 0.25rem) * 4);
}
```


Fixes: #20256
Fixes: #20258

## Test plan

1. Added a regression test to make sure this doesn't happen anymore
2026-06-18 15:02:18 +02:00
..
@tailwindcss-browser 4.3.1 (#20226) 2026-06-12 19:33:35 +02:00
@tailwindcss-cli Ensure @tailwindcss/cli watches the input file (#20246) 2026-06-16 18:38:29 +02:00
@tailwindcss-node Fix crash when using @tailwindcss/vite using deno v2.8.x (#20245) 2026-06-16 16:03:27 +02:00
@tailwindcss-postcss 4.3.1 (#20226) 2026-06-12 19:33:35 +02:00
@tailwindcss-standalone Update all pnpm dependencies (2026-06-15) (#20241) 2026-06-15 13:13:32 +00:00
@tailwindcss-upgrade 4.3.1 (#20226) 2026-06-12 19:33:35 +02:00
@tailwindcss-vite 4.3.1 (#20226) 2026-06-12 19:33:35 +02:00
@tailwindcss-webpack 4.3.1 (#20226) 2026-06-12 19:33:35 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Ensure --alpha(…) is seen as a color, and --spacing(…) is seen as a length (#20260) 2026-06-18 15:02:18 +02:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00