tailwindcss/packages/tailwindcss
Philipp Spiess dc6980230d
Fix CSS theme() function resolution issue (#14614)
We currently have three different implementations of the
`resolveThemeValue()` Theme method:

1. The _core_ version which only resolves based on the exact CSS
variable name. This is the v4-only version.
2. A _compat light_ version which attempts to translate a dot-notation
keypath to a CSS variable name.
3. A _full compat_ version which resolves the legacy theme object which
is used whenever a `@plugin` or `@config` is added.

Unfortunately, there are some issues with this approach that we've
encountered when testing the CSS `theme()` function while upgrading
Tailwind Templates to v4 using our upgrading toolkit.

1. The _compat light_ resolver was trying to convert `theme(spacing.1)`
to tuple syntax. Tuples require a nested property access, though, and
instead this should be convert to `theme(--spacing-1)`.
2. We currently only load _full compat_ version if `@plugin` or
`@config` directives are used. It is possible, though, that we need the
full compat mapping in other cases as well. One example we encountered
is `theme(fontWeight.semibold)` which maps to a dictionary in the
default theme that that we do not have an equivalent for in v4
variables.

To fix both issues, we decided to remove the _compat light_ version of
the `theme()` function in favor of adding this behavior to an upgrade
codemod. Instead, the second layer now only decides wether it can use
the _core_ version or wether it needs to upgrade to the _full compat_
version. Since typos would trigger a _hard error_, we do not think this
has unintended performance consequences if someone wants to use the
_core_ version only (they would get an error regardless which they need
to fix in order to continue).
2024-10-10 12:31:46 +02:00
..
src Fix CSS theme() function resolution issue (#14614) 2024-10-10 12:31:46 +02:00
tests Preserve explicit transition duration and timing function when overriding transition property (#14490) 2024-09-23 10:43:28 -04:00
index.css introduce v4 codebase 2024-03-05 14:29:15 +01:00
package.json Add *.js export variants for compat files (#14595) 2024-10-04 15:38:55 +02:00
playwright.config.ts Only apply hover on devices that support hover (#14500) 2024-09-24 11:43:57 -04:00
preflight.css Don't set display: none on elements that use hidden="until-found" (#14631) 2024-10-09 13:55:58 +02:00
README.md Copy README file to every package (#13096) 2024-03-06 08:49:31 -05:00
theme.css Add default option to @theme to support overriding default theme values from plugins/JS config files (#14327) 2024-09-04 11:49:50 -04:00
tsconfig.json introduce v4 codebase 2024-03-05 14:29:15 +01:00
tsup.config.ts Throw a useful error when tailwindcss is used as a PostCSS plugin (#14378) 2024-09-11 17:02:24 +02:00
utilities.css introduce v4 codebase 2024-03-05 14:29:15 +01:00
vitest.config.ts Add integration test setup and tests for the Vite integration (#14089) 2024-08-02 11:50:49 +02:00

Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Tailwind CSS on GitHub

For chatting with others using the framework:

Join the Tailwind CSS Discord Server

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.