tailwindcss/packages
Robin Malfait 4a4be27dc1
Migrate theme(…) to var(…) in CSS (#14695)
This PR is a follow up from https://github.com/tailwindlabs/tailwindcss/pull/14664 migrates all the `theme(…)` calls in your CSS to `var(…)` if we can.

In at-rules, like `@media` we can't use `var(…)` so we have to use the modern version of `theme(…)`.

In declarations, we can convert to `var(…)` unless there is a modifier used in the `theme(…)` function, then we can only convert to the new `theme(…)` syntax without dot notation.

Input:
```css
@media theme(spacing.4) {
  .foo {
    background-color: theme(colors.red.900);
    color: theme(colors.red.900 / 75%); /* With spaces around the `/` */
    border-color: theme(colors.red.200/75%); /* Without spaces around the `/` */
  }
}
```

Output:
```css
@media theme(--spacing-4) {
/*     ^^^^^^^^^^^^^^^^^^     Use `theme(…)` since `var(…)` is invalid in this position*/
  .foo {
    background-color: var(--color-red-900); /* Converted to var(…) */
    color: theme(--color-red-900 / 75%); /* Convert to modern theme(…) */
    border-color: theme(--color-red-200 / 75%); /* Convert to modern theme(…) — pretty printed*/
  }
}
```
2024-10-17 11:50:27 +02:00
..
@tailwindcss-cli Release v4.0.0-alpha.27 (#14671) 2024-10-15 10:28:34 +00:00
@tailwindcss-node Release v4.0.0-alpha.27 (#14671) 2024-10-15 10:28:34 +00:00
@tailwindcss-postcss Add first draft of new wide-gamut color palette (#14693) 2024-10-16 15:24:53 -04:00
@tailwindcss-standalone Release v4.0.0-alpha.27 (#14671) 2024-10-15 10:28:34 +00:00
@tailwindcss-upgrade Migrate theme(…) to var(…) in CSS (#14695) 2024-10-17 11:50:27 +02:00
@tailwindcss-vite Release v4.0.0-alpha.27 (#14671) 2024-10-15 10:28:34 +00:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Add first draft of new wide-gamut color palette (#14693) 2024-10-16 15:24:53 -04:00
tsconfig.base.json introduce v4 codebase 2024-03-05 14:29:15 +01:00