tailwindcss/packages/@tailwindcss-upgrade/src
Philipp Spiess ca7b10e7d3
Make --theme(…) return CSS variables (#17036)
Closes #16945

This PR changes the `--theme(…)` function now return CSS `var(…)`
definitions unless used in places where `var(…)` is not valid CSS (e.g.
in `@media (width >= theme(--breakpoint-md))`):

```css
/* input */
@theme {
  --color-red: red;
}
.red {
  color: --theme(--color-red);
}

/* output */
:root, :host {
  --color-red: red;
}
.red {
  color: var(--color-red);
}
```

Furthermore, this adds an `--theme(… inline)` option to the `--theme(…)`
function to force the resolution to be inline, e.g.:

```css
/* input */
@theme {
  --color-red: red;
}
.red {
  color: --theme(--color-red inline);
}

/* output */
.red {
  color: red;
}
```

This PR also changes preflight and the default theme to use this new
`--theme(…)` function to ensure variables are prefixed correctly.

## Test plan

- Added unit tests and a test that pulls in the whole preflight under a
prefix theme.
2025-03-20 12:51:22 +01:00
..
codemods Make --theme(…) return CSS variables (#17036) 2025-03-20 12:51:22 +01:00
commands/help Add initial codemod tooling (#14434) 2024-09-18 16:45:43 +02:00
template Make --theme(…) return CSS variables (#17036) 2025-03-20 12:51:22 +01:00
utils Upgrade: Report errors when updating dependencies (#16504) 2025-02-13 16:02:59 +01:00
index.test.ts Revert new default form styles (#15100) 2024-11-22 08:55:05 -05:00
index.ts Upgrade: Use latest tag for packages (#16620) 2025-02-18 11:57:51 +01:00
migrate-js-config.ts Upgrade: Handle darkMode value with block syntax (#16507) 2025-02-14 16:48:52 +01:00
migrate-postcss.ts Upgrade: Use latest tag for packages (#16620) 2025-02-18 11:57:51 +01:00
migrate-prettier.ts Improve robustness when upgrading (#15038) 2024-11-19 14:29:51 +01:00
migrate.ts Fix handling of absolute config files in upgrade tool (#15927) 2025-01-28 12:42:30 +01:00
stylesheet.ts Resolve imports from CSS file (#15010) 2024-11-15 22:06:52 +01:00